我正在尝试打开并从Phonegap读取XML文件,但出现此CORS错误。我该如何解决这个问题?
XMLHttpRequest cannot load file://localhost/../data/file.xml. Origin null is not allowed by Access-Control-Allow-Origin.
来电者代码是:
var request = $.ajax({
type: "GET",
url: "data/file.xml",
async: false,
dataType: "xml"
});
由于解释here:
,我的代码中也有此代码段$(document).on( "mobileinit", function() {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
});
答案 0 :(得分:1)