local AJAX-call to remote site works in Safari but not in other browsers

后端 未结 4 967
日久生厌
日久生厌 2020-12-19 04:54

I am maintaining a website that uses Javascript. The script uses jQuery and loads some content from the server at which the site is normally hosted.

Just for conveni

4条回答
  •  不知归路
    2020-12-19 05:44

    Due to the same origin policy you aren't normally able to request resources from a different domain. Try adding crossDomain: true to your AJAX request since you are trying to make a request to a different domain.

    $.ajax({
        url: 'http://my.domain.tld/cgi-bin/myPerlScript.pl',
        crossDomain: true,
        data: "lastID=" + lastID
           + '&qkz=' + Math.random(),
           dataType: "json",
           success: JSONreceive,
           error: JSONerror
    });
    

提交回复
热议问题