开发者

How to send data to a web service in another domain

开发者 https://www.devze.com 2023-04-01 10:07 出处:网络
I need to send data using javascript or jquery to a web service located on another domain. I know how to d开发者_如何转开发o this using JSONP and Http GET for the web service. But this means all data

I need to send data using javascript or jquery to a web service located on another domain. I know how to d开发者_如何转开发o this using JSONP and Http GET for the web service. But this means all data must be passed in the url. In my case, the data can be a few KB or more so it does not work all the time. I think i need to use HTTP POST instead.

Can anyone give me an example on how to get this done? Can I use JQuery post() method for cross domain?


jQuery POST for another domain is not legal, and not so-allowed.

The best way would be passing the POST data to a 'bridge-script' on your own domain using jQuwry, where that script will transparently post the data using cURL.

cURL of course can 'forge' the posting/referring domain so that it appears legal.

Google it, I'm not sure if we are allowed to post such answers ;)

Useful Link:

  • http://curl.haxx.se/docs/httpscripting.html
  • https://superuser.com/questions/149329/how-do-i-make-a-post-request-with-the-curl-command-line-tool
0

精彩评论

暂无评论...
验证码 换一张
取 消