[問題] 請問Exception相關問題(ashx 搭配jQuery)
ashx code
try
{
XXXXXXX
context.Response.Write(JsonConvert.SerializeObject(dt));
}
catch (Exception ex)
{
context.Response.Write(ex.ToString());
}
jQuery
$.ajax({
type: "post",
url: "XXXX.ashx",
data: 'StartMonth=' + $("#txtStartMonth").val() + "&EndMonth=" +
$("#txtEndMonth").val(),
success: function (response, status, xhr) {
ParseCTMData(response);
},
error: function (xhr, status, error) {
console.log('xhr---->');
console.log(xhr.status);
console.log(xhr);
console.log('<----xhr');
console.log('status---->');
console.log(status);
console.log('<----status');
console.log('error---->');
console.log(error);
console.log('<----error');
alert('error code:' + xhr.status + ',error message:' + error);
}
})
如果ashx中真的有error產生,jQuery還是會掉到success中的迴圈,不會跑到error中
,請問要如何設計exception handle較好呢?
感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.130.45.113
推
08/24 18:09, , 1F
08/24 18:09, 1F
推
08/24 18:50, , 2F
08/24 18:50, 2F
→
08/24 21:43, , 3F
08/24 21:43, 3F
→
08/24 23:04, , 4F
08/24 23:04, 4F
→
08/25 10:09, , 5F
08/25 10:09, 5F
→
08/25 10:10, , 6F
08/25 10:10, 6F
→
08/25 10:11, , 7F
08/25 10:11, 7F
→
08/25 12:31, , 8F
08/25 12:31, 8F
→
08/25 12:33, , 9F
08/25 12:33, 9F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章