【发布时间】:2014-04-16 19:47:42
【问题描述】:
我正在为基于 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.
我怎样才能让我的 Django 应用程序允许某些 url 跨源?
这是我的 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);
});
});
}
【问题讨论】:
-
从未使用过 Django,但是您是否将服务器添加到您的 cordova/phonegap 白名单?
-
你是怎么做到的?不知道您可以将服务器白名单添加到 cordova/phonegap 应用程序
-
在我的 config.xml 我已经有默认的
<access origin="*" /> -
感谢@MBillau 的提示
标签: python ajax django cordova cors