我正在为基于Django的应用程序开发一个Phonegap应用程序,但在尝试进行Ajax调用时出现此错误:
XMLHttpRequest cannot load http://domain.herokuapp.com/getcsrf/?tags=jquery%2Cjavascript&tagmode=any&format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做我的Django应用程序允许一些网址的交叉起源?
这是我的Ajax代码:
get: function() {
$.getJSON("http://domain.herokuapp.com/getcsrf/",
{
tags: "jquery,javascript",
tagmode: "any",
format: "json"
},
function(data) {
$.each(data.items, function(item){
console.log(item);
});
});
}
Run Code Online (Sandbox Code Playgroud)