XHR状态的JQuery Ajax错误为0;意思是没有连接

时间:2016-01-07 07:34:57

标签: jquery ajax

我有以下代码片段

   $.ajax({
            method  :   "GET",
            url     :   'http://projectstorehouse.com/travelnews/index.html',
            data    :   "",
            success :   function(){
                            alert("Hello");
                        },
            error   :   function(jqXHR, status, error){
                        if (jqXHR.status === 0) {
                            alert('Not connected.\nPlease verify your network connection.');
                        } else if (jqXHR.status == 404) {
                            alert ('The requested page not found. [404]');
                        } else if (jqXHR.status == 500) {
                            alert ('Internal Server Error [500].');
                        } else if (exception === 'parsererror') {
                            alert ('Requested JSON parse failed.');
                        } else if (exception === 'timeout') {
                            alert ('Time out error.');
                        } else if (exception === 'abort') {
                            alert ('Ajax request aborted.');
                        } else {
                            alert ('Uncaught Error.\n' + jqXHR.responseText);
                        }
            }
        });

并无法找出与之相关的问题;显示的消息是jqXHR.status == 0。可以访问网址http://projectstorehouse.com/travelnews/index.html

有人可以告诉我哪里错了;

0 个答案:

没有答案