Make my jQuery Ajax script use CORS

為{幸葍}努か 提交于 2019-12-06 13:08:43

you are probably hitting the domain (ontariosheep.org) from other domain name, and that brings the cross-domain into the poll.

CORS is just a way to solve this, and it has to be your server that hosts data_all.php that needs to be set to also have in the response header the property:

Access-Control-Allow-Origin: *

or, you can use the other common method called JSONP.

using JSONP method, you call should look like:

var url = "http://ontariosheep.org/mobile/data/data_all.php";
$.get(url + "?callback=?", function(data) {
    // your method body     
});

You could turn on CORS in jquery specifically with

$.support.cors = true;

Also, make sure to configure your widget config correctly (config.xml) and add

<access uri="*" /> 

or at least

<access uri="ontariosheep.com" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!