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...)
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(),
dataT开发者_如何学JAVAype: "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. is there any way to set the ajax to async: false, by not changing the function and using it.....
Something like this perhaps?
just call the following function with 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);
精彩评论