PhoneGap ajax call fails everytime

后端 未结 6 1929
臣服心动
臣服心动 2021-01-15 12:27

I am developing a mobile application using PhoneGap, and I have to access some services from another project. I am using jquery-2.0

6条回答
  •  伪装坚强ぢ
    2021-01-15 13:32

    (For people with similiar problems) Use ajax error to know what is wrong:

        error: function(jqXHR, exception){          
            var msg = '';
            if (jqXHR.status === 0) {
                msg = 'Not connect.\n Verify Network.';
            } else if (jqXHR.status == 404) {
                msg = 'Requested page not found. [404]';
            } else if (jqXHR.status == 500) {
                msg = 'Internal Server Error [500].';
            } else if (exception === 'parsererror') {
                msg = 'Requested JSON parse failed.';
            } else if (exception === 'timeout') {
                msg = 'Time out error.';
            } else if (exception === 'abort') {
                msg = 'Ajax request aborted.';
            } else {
                msg = 'Uncaught Error.\n' + jqXHR.responseText;
            }
            console.log(msg);
        }
    

提交回复
热议问题