How Do I Set A Timeout In Load Jquery For This Particular Example?
Solution 1:
jQuery load()
method doesn't accept any settings
param. So you have to replace it with more low-level method ajax() call - which lets you specify timeout
settings for this specific request. One possible way to do it:
$.ajax('compare_proc.php', {
data: 'id=' + first_id + '&id2=' + second_id,
timeout: someTimeoutInMs,
success: function(resp) {
$('#test').html(resp);
}
});
The alternative is to leave your code as is, but modify global AJAX settings instead with ajaxSetup() call (prior to calling load
). Note that using this API is strongly discouraged on its very documentation page:
The settings specified here will affect all calls to
$.ajax
or AJAX-based derivatives such as$.get()
. This can cause undesirable behavior since other callers (for example, plugins) may be expecting the normal default settings. For that reason we strongly recommend against using this API. Instead, set the options explicitly in the call or define a simple plugin to do so.
Still, in your case (when only timeout settings are changed) it may be ok to go that way as well.
Post a Comment for "How Do I Set A Timeout In Load Jquery For This Particular Example?"