未执行 Windows Phone jQuery ajax 回调的 Phonegap [英] Phonegap for Windows Phone jQuery ajax callback not executed

查看:20
本文介绍了未执行 Windows Phone jQuery ajax 回调的 Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Phonegap for 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); 
    }
});

有什么想法吗?

推荐答案

这似乎是 phone gap 1.3.0 中本地 XHR shim 实现的一个已知问题.您可以切换到以前的版本或注释 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);

编辑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.

这篇关于未执行 Windows Phone jQuery ajax 回调的 Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆