设置超时jQuery.load() [英] Setting timeout jQuery.load()
本文介绍了设置超时jQuery.load()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个事件,点击时启动一个jQuery的load()。负载通过几MB的POST数据。我正在中止错误。如何设置超时?
toggleModalLoading();
$(#ele).load('http://site.com/script.php',{
'数据':POSTDATA},
功能(E){
toggleModalLoading();
});
解决方案
在 .load()
通话仅仅是一个方便的速记。你可以设置全局AJAX选项中的 .load()<前/ code>通话。如果这是不可行的,你将不得不使用较低级别的API 。无论哪种方式,你想要的
暂停
AJAX选项:
$。阿贾克斯('http://site.com/script.php',{
数据:POSTDATA,
超时:1000 // 1000毫秒
成功:功能(数据){
$('#ELE)HTML(数据)。
toggleModalLoading();
}
});
I have an event that when clicked initiates a jQuery load(). The load passes several MB of POST data. I am getting aborted errors. How can I set the timeout?
toggleModalLoading();
$("#ele").load('http://site.com/script.php',{
'data' : postData },
function(e) {
toggleModalLoading();
});
解决方案
The .load()
call is really just a convenient shorthand. You could set global ajax options before the .load()
call. If that's not viable, you'll have to use the lower-level API. Either way, you want the timeout
ajax option:
$.ajax('http://site.com/script.php', {
data: postData,
timeout: 1000, // 1000 ms
success: function (data) {
$('#ele').html(data);
toggleModalLoading();
}
});
这篇关于设置超时jQuery.load()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文