0

I've been stuck here for quite some time now. I am developing a mobile application with phonegap. I have tested the app with android 4.0.4 and it is working perfectly fine. However, when I tested on 2.2.3, the AJAX ended with and error state of:

ready state = 0

HTTP Status = 0

I have tried to increase the timeout to be really long but it still ends with that result. I am not sure what is the problem but I have developed another app using the same ajax call and it is working fine on android 2.2.3 but what makes this time different is that it calls to a SAML URL (Identity Provider).

the codes is like bellow:

$.ajax({
                url: "...."+Math.random(),
                type: "POST",
                data: {
                    j_username: uname,
                    j_password: pword
                },
                cache: false,
                timeout: (100*1000),
                success: function(data, textStatus, jqXHR){
                    var contentType = jqXHR.getResponseHeader('Content-Type');
                    if (contentType == 'application/atomsvc+xml'){
                    }else{
                        alert(".....");
                        // clearTimeout(timer);
                        $.mobile.hidePageLoadingMsg();
                        enableAllButtons();
                    }
                },
                error: function(jqXHR, textStatus, errorThrown){
                    // clearTimeout(timer);
                    alert("Error Thrown : " + errorThrown);
                    alert("status : " + jqXHR.status + " " + jqXHR.statusText);
                    alert("ready state : " + jqXHR.readyState);
                    alert(".......");
                    $.mobile.hidePageLoadingMsg();
                    enableAllButtons();
                }
            });  

Really hope someone can help me with this.

Thank you very much for your input in advance.

Regards,

Amanda

4

1 回答 1

0

代码似乎很好,除了一件事

Math.random()在 URL 中使用..您还使用cache:false Try to remove the Math.random()from URL 而 jQuery Cache 使用相同的东西。

此外,当你得到readyState = 0它时,这将是一个跨域问题。dateType:'JSONP'在 AJAX 选项中使用 JSONP ( )

于 2013-03-28T07:13:55.813 回答