Loading...

ajax錯誤訊息提示

Temperature: 0 °C

Mark ChangMark Chang
author_tools


ajax錯誤訊息提示
ajax目前已經是我寫系統使用非常普遍的方式~

雖說常寫,但偶爾還是會有鬼打牆的時候發生.......

這邊記錄一下要如何知道傳送錯誤的類型。

$.ajax({
type: 'GET',
url: headerUrl,
dataType: 'html',
success: function(data) {
$('#header').append(data);
},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;
}

alert(msg)

總之~學不完的知識。
 

https://innstory.com/story-ajax錯誤訊息提示-1766
javascript

Prev
 分享_缺電救星出現了日本開發颱風發電機一場颱風就蘊藏50年電力不用實在太浪費!風傳媒

Next
使用Google提供的檢查網頁工具檢查是否為惡意網站 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

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

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

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

Font Awesome Icon Sizes

Font Awesome I...

pexelsphotoicon5 紀錄一下Font Awesome icon尺寸設定 faxs fa...

PDO PHP - PDOException - Numeric value out of range: 1264 Out of range value for column user_ip at row 1

PDO PHP - PDOE...

最近遇到一個問題,一個Mysql的錯誤訊息。 我想要紀錄一個IP資訊,我會先用以下方式擷取用戶端使用...

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