jquery ajax调用不会触发错误回调

时间:2012-03-12 10:30:50

标签: ajax cordova callback

大家好,我正在使用带有jQuery 1.6.4和jQuery Mobile 1.0.1的PhoneGap 1.5.0,我正在尝试对xml文件进行简单的ajax调用。这一切都很有效,但是如果我将URL或凭证更改为无效值,则不会调用错误方法。

$
        .ajax({
            url : "url be here",
            dataType : "xml",
            contentType : 'application/xml',
            username : username,
            password : password,
            success : function(xmlData, textStatus, xhr) {
              //this is triggered on success
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
              //this is never called
            }
        });

我无法弄明白,我在这里做错了什么。 :(

1 个答案:

答案 0 :(得分:1)

将错误功能签名更改为:

  function( jqXHR, error_textStatus, errorThrown)