【发布时间】:2010-03-08 19:06:50
【问题描述】:
我正在对有时返回无法解析的 JSON 的服务器进行 AJAX 调用。服务器不在我的控制之下,所以我无法修复它。
function eventFunction(evt) {
$('div#status_bar').show();
$.ajax({
url: 'http://buggyserver.com/api/',
type: 'GET',
data: { 'mode': 'json', 'q': 'get/data' },
dataType: 'json',
success: updateForm
});
}
function updateForm(returned, status) {
if (status == 'success') {
//Update the form here
}
$('div#status_bar').hide();
}
返回不可解析的 JSON 时,不会调用 updateForm 函数。
我如何在客户端确保updateForm 函数的最后一行被调用以隐藏状态栏?我尝试在 AJAX 调用和 updateForm 周围放置 try { } catch {} 子句。
【问题讨论】:
标签: javascript json jquery