Reputation: 5724
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.
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;
Upvotes: 0
Views: 301
Reputation: 46008
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.
Upvotes: 1