Is there any way I can run this code with async:false? I notice the jQuery manual specifies that it must be true, when passing the call return to a variable, but that is painful considering the method is meant to be generic.
有没有办法用async运行这段代码:false?我注意到jQuery手册在将调用返回传递给变量时指定它必须为true,但考虑到该方法是通用的,这很痛苦。
ajaxCall.classFunction = function( $class, $function, $params){
//Ensure no errors occured
$params = typeof($params) != 'undefined' ? $params : false;
//Ajax Call for data
var $r =$.ajax({
type: 'POST',
url: 'json.php?c='+$class+'&func='+$function,
data: $params,
timeout:5000,
async:false,
}).responseText;
return $r;
1 个解决方案
#1
1
No, you will have to specify success callback. With async set to true your outer method is not blocked and returns immediately without waiting for the actual response for your ajax call.
不,您必须指定成功回调。将async设置为true时,不会阻止外部方法并立即返回,而不等待ajax调用的实际响应。
#1
1
No, you will have to specify success callback. With async set to true your outer method is not blocked and returns immediately without waiting for the actual response for your ajax call.
不,您必须指定成功回调。将async设置为true时,不会阻止外部方法并立即返回,而不等待ajax调用的实际响应。