PhoneGap for Windows Phone jQuery ajax回调未执行 [英] Phonegap for Windows Phone jQuery ajax callback not executed
问题描述
我有Phonegap的Windows Phone和jQuery的问题。
I have a problem with Phonegap for Windows Phone and jQuery.
我有一个Ajax请求到远程服务器,但成功回调不执行,即使服务器响应200代码(我可以看到服务器中的请求access_log)。
I have an Ajax request to a distant server, but the success callback is not executed even if the server respond with a 200 code (I can see the request in the server access_log). The error callback is not executed either.
代码
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.ajax({
url: 'http://example.com',
data: { foo: 'bar' },
cache: false,
dataType: 'json',
success: function (data) {
console.log(data);
}
});
有什么想法吗?
推荐答案
这似乎是一个已知的问题,本地XHR垫片实施在手机差距1.3.0。您可以切换到上一个版本或评论phonegap-1.3.0.js中从第3551行到文件结尾的所有内容
It seems to be a known issue of local XHR shim implementation in phone gap 1.3.0. You can switch to previous version or comment everything in phonegap-1.3.0.js starting from line 3551 to the end of the file
//(function(win,doc){
//
// doc.addEventListener("DOMContentLoaded",function()
// {
// ......
// if(!docDomain || docDomain.length == 0)
// {
// //console.log("adding our own Local XHR shim ");
// var aliasXHR = win.XMLHttpRequest;
//
// win.XMLHttpRequest = function(){};
//
// var UNSENT = 0;
// ......
//
//
//})(window,document);
EDIT
提交PhoneGap 1.4.0rc1
EDIT PhoneGap 1.4.0rc1 is commited
https://github.com/purplecabbage/callback-windows-phone
更改包括将XHR修复到本地文件,+修复以允许jQM单/多页应用程序正常运行。
Changes include fixes for XHR to local files, + fixes to allow jQM single/multipage apps function correctly.
这篇关于PhoneGap for Windows Phone jQuery ajax回调未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!