Loading...

要如何知道ajax執行失敗原因?

Temperature: 0 °C

Mark ChangMark Chang
author_tools

只要在error的function 更改為以下寫法即可:

error: function (XMLHttpRequest, textStatus, errorThrown) {
// $("#getinfo").innerHTML = "there is something wrong!";
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
}

出現錯誤都會跳到error函數裏

底下為XMLHttpRequest:XMLHttpRequest.readyState狀態碼的意思:
0 - (未初始化)還沒有調用send()方法
1 - (載入)已調用send()方法,正在發送請求
2 - (載入完成)send()方法執行完成,已經接收到全部響應內容
3 - (交互)正在解析響應內容
4 - (完成)響應內容解析完成,可以在客戶端調用了

以上紀錄。
 

https://innstory.com/story-要如何知道ajax執行失敗原因-2397
javascript

Prev
 PDO_bindParam_和_bindValue_差別在哪裡

Next
分享_首度載人試飛成功!日本新創SkyDrive拚2023年造出飛天計程車、30年後人人可搭|數位時代 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

Linux底下查看Mysql版本

Linux底下查看Mysql...

在OS底下 [root@localhost ~]# mysql V 在Mysql底下 mysql> ...

php檢查陣列中大於0的值

php檢查陣列中大於0的值

假設有一個陣列$a $a = array(,,,,,,); 取得大於的數值有幾個 $tempa = ...

當域名 DNS 尚未生效時,如何預先設定及測試網站

當域名 DNS 尚未生效時,...

建置一個新的網站或是將網站搬家時 常常會遇到一個問題,就是要將網址指向到新的網站空間,設定完畢但需要...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format