相关疑难解决方法(0)

使用Phonegap访问Django应用程序中的Access-Control-Allow-Origin

我正在为基于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)

python django ajax cors cordova

41
推荐指数
4
解决办法
7万
查看次数

标签 统计

ajax ×1

cordova ×1

cors ×1

django ×1

python ×1