在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ ajax返回readyState為0?

ajax返回readyState為0?

請求ajax報錯, XMLHttpRequest對象返回readyState:0, status:0

相關(guān)代碼

function login(){
          var phone = '18600000000';
          var password = '123456';
          var serverurl = 'http://apiym.xnsoft.net.cn/ApiInterface.ashx?action='
          console.log("手機號--" + phone);
          console.log("密碼--" + password);
          $.ajax({
              type:'POST',
              url:serverurl + 'MemberLogin',
              dataType:'json',
              data:{
                  'Phone': phone,
                  'Pwd': password,
                  'PwdType': 0
              },          
              success:function(ret){
                  console.log(JSON.stringify(ret));
              },
              error:function(XMLHttpRequest, textStatus, errorThrown){
                  console.log("XMLHttpRequest--"+JSON.stringify(XMLHttpRequest));
                  console.log("textStatus---"+JSON.stringify(textStatus));
                  console.log("errorThrown--"+JSON.stringify(errorThrown));
              }
          })
      }

返回錯誤信息如下:

XMLHttpRequest--{"readyState":0,"status":0,"statusText":"error"} at login.html : 228
textStatus---"error" at login.html : 229
errorThrown--"" at login.html : 230

clipboard.png

請教一下readyState為什么返回狀態(tài)碼為0未初始化,沒有發(fā)送到請求,該怎么解決?

回答
編輯回答
兔寶寶

加了這兩個參數(shù)就OK了

async: false, // 使用同步操作
timeout: 50000, //超時時間:50秒

其實是同事用了form標(biāo)簽,或者直接去掉form表單的標(biāo)簽就行了

2017年5月7日 03:30
編輯回答
舊言

看看是不是外網(wǎng)訪問內(nèi)網(wǎng)手限制了

2017年10月13日 04:37