![](/img/trans.png)
[英]Ajax jQuery picture upload - newbie question whats the best way to handle this?
[英]Whats the best way to implement an AJAX timeout?
如果Web服務器出現故障,我試圖使AJAX請求超時。 有人有這樣做的好方法嗎?
jQuery提供了一個漂亮的解決方案
$.ajax({
type: "GET",
timeout: 5000,
url: "myurl.com",
success: function(data) {
alert('Data load: '+ data);
},
error: function(){
alert('Error loading data');
}
});
取決於您使用的框架。 例如, jQuery.ajax
支持執行此操作的timeout
選項。 您也可以使用jQuery.ajaxSetup
對其進行全局設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.