Odd jQuery problem - Ajax request to a C program not quite working

后端 未结 1 893
旧时难觅i
旧时难觅i 2020-12-22 10:36

I have this basic setup:

  • C program opens a socket on a specific unused port (let\'s say 1234) and waits, listening specifically for HTTP requests.
  • Web
相关标签:
1条回答
  • 2020-12-22 10:59

    A different port on the same website still violates the XHR Cross domain policy. The only way it could work cross-domain is either JSONP (does not support POST requests) or a proxy webservice on the same server.

    JSONP is the easiest, what it does is basically just add a <script> tag to your <head> to the url, which would perform a GET request (so bye bye postdata). And you can make it call a javascript callback by adding a "callback=?" GET parameter to the url - the response would then have to call the javascript method named in the 'callback' parameter. If that makes sense..

    jQuery is probably detecting that it is a remote URL and tries to use JSONP, but because there are no callbacks made it fails (and error does not get called either).

    0 讨论(0)
提交回复
热议问题