postman有跨網域神力啊
今天幫賈賈查個東西
要怎麼把curl 的action轉成js或者jquery的ajax code
恩....
看起來是完全可行的(畢竟我是個菜鳥
但我從六點多開始試到凌晨一點多都是失敗的....不論各種debug, 自己開web api比對resource, response
後來利用了"postman cross domain" 以及 "curl cross domain" 查到了
Regular web pages can use the XMLHttpRequest object to send and receive data from remote servers, but they're limited by the same origin policy. Extensions aren't so limited. An extension can talk to remote servers outside of its origin, as long as it first requests cross-origin permissions.
要怎麼把curl 的action轉成js或者jquery的ajax code
恩....
看起來是完全可行的(畢竟我是個菜鳥
但我從六點多開始試到凌晨一點多都是失敗的....不論各種debug, 自己開web api比對resource, response
後來利用了"postman cross domain" 以及 "curl cross domain" 查到了
Regular web pages can use the XMLHttpRequest object to send and receive data from remote servers, but they're limited by the same origin policy. Extensions aren't so limited. An extension can talk to remote servers outside of its origin, as long as it first requests cross-origin permissions.
Ajax calls can only be made to URLs within the same domain.
然後有一篇神文說“你可以用jquery ajax 做到cross domain",他的方法是利用jquery ajax傳給一個php頁面,再讓php用curl的方式把remote data吐回來,好複雜啊這~
文章的最後,到底為什麼postman可以cross domain而我就不行呢?https://developer.chrome.com/extensions/xhr
google developer的文章中有寫道
(非拿不可的話,似乎可以用JSONP或者CORS來解
留言
張貼留言