我正尝试从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"
});
由于这里的解释,我在我的代码中也有这段片段:
$(document).on( "mobileinit", function() {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
});