[英]ajax function and async: false
here got a weird situation ..... 这里有一个奇怪的情况.....
i got a function that cannot edit.(for some reason and i need to use it instead of create a new 1, or overwrite the script is not allowed...) 我有一个无法编辑的函数。(由于某种原因,我需要使用它而不是创建一个新的1,否则不允许覆盖脚本...)
function update_tpl2(form, divtoupdate, exeAlert) {
if(!$('#'+form).length)
form = 'myform';
if(!$('#'+divtoupdate).length)
divtoupdate = 'ajax_update';
$.ajax({
type: "POST",
url: url,
data: $('#' + form).serialize(),
dataType: "html",
beforeSend: ShowLoading,
success: function(resp){
$('#theLoading').dialog('close');
$('#loading').html('');
$('#' + divtoupdate).html(resp);
}
});
} }
and i need to add async: false into that function when run. 并且我需要在运行时向该函数添加async:false。 is there any way to set the ajax to async: false, by not changing the function and using it.....
有没有办法通过不更改功能并使用它来将ajax设置为async:false?
Something like this perhaps? 大概是这样吗?
just call the following function with properties = { async: false } 只需使用properties = {async:false}调用以下函数
function update_tpl2(form, divtoupdate, exeAlert, properties) {
if(!$('#'+form).length)
form = 'myform';
if(!$('#'+divtoupdate).length)
divtoupdate = 'ajax_update';
var defaultProps = {
type: "POST",
url: url,
data: $('#' + form).serialize(),
dataType: "html",
beforeSend: ShowLoading,
success: function(resp){
$('#theLoading').dialog('close');
$('#loading').html('');
$('#' + divtoupdate).html(resp);
}
}
jQuery.extend( true, defaultProps, properties)
$.ajax(defaultProps);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.