JQMobi + PhoneGap: Ajax延迟承诺方法不工作

JQMobi + PhoneGap: Ajax Deferred promise methods not working

本文关键字:承诺 方法 工作 延迟 Ajax PhoneGap JQMobi      更新时间:2023-09-26

这两天我一直在考虑这个问题。我认为JQMobi(Intel AppFramework)是JQuery的轻量级版本,加上针对移动设备(iOS和Android)定制的UI框架。在许多网站和博客上阅读了很多关于JQuery Deferred()方法的内容,并尝试在我的一个使用JQMobi的phonegap项目中实现一些示例。我的ajax调用被正确触发,并且成功回调成功:

$.ajax({
        url: 'http://drsolution.com.br/teste/texts.json',
        async: true,
       dataType:'json',
       success: function(data)
        {
         // do something with the json object, THIS IS ALWAYS WORKING
        },
       error: function(error)
       {
        console.log("error");
       }
      });

但是当我尝试在ajax调用返回的承诺对象中使用延迟回调方法时,我没有得到它们的响应:

$.ajax({
        url: 'http://drsolution.com.br/teste/texts.json',
        async: true,
        dataType:'json',
        success: function(data)
        {
         // do something with the json object, THIS IS ALWAYS WORKING
        },
        error: function(error)
        {
          console.log("error");
        }
        }).done(function{
                        // never fired
                        }).fail(function {
                                         // never fired
                                         }).always(function {
                                                            //never fired
                                                            });

发生了什么事?延迟对象在JQMobi (Intel AppFramework)中没有实现?

提前感谢。

注意我是App Framework的作者

App Framework (jqMobi)是不是 jQuery。它提供了类似于jQuery的语法。

deferred/done/fail/always在App Framework中不被实现。