0
如何在JQuery錯誤處理函數中添加$ .get? 我的請求看起來像
$.get('www.test.com', temp_parameters, function(data) {
alert('data='+data['result']);
},"json");
但如果發生錯誤,則沒有功能。在哪裏添加該功能?
如何在JQuery錯誤處理函數中添加$ .get? 我的請求看起來像
$.get('www.test.com', temp_parameters, function(data) {
alert('data='+data['result']);
},"json");
但如果發生錯誤,則沒有功能。在哪裏添加該功能?
如果您使用jQuery 1.5或更高版本,您可以添加錯誤方法。
段從 - http://api.jquery.com/jQuery.get/
var jqxhr = $.get("example.php", function() {
alert("success");
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });
你可以閱讀更多關於它。除此之外,Flex提到$ .ajax是最好的選擇。
使用'$ .ajax':http://api.jquery.com/jQuery.ajax/ –