Welcome,
I want to call synchronous javascript method without callbacks. The method is a POST asynchronous.
function someMethod() {
var bean; //bean is a proxy object provide by external library
if(clicked_onSpecial_field) {
if(!bean.isAuthorized()) { //here is a async call
return false;
}
}
//a lot of other instructions...
}
From one hand usually clicked_onSpecial_field = false
so I cannot put all other instructions in callback.
From the another hand bean
is a provide to me proxy object. In this case i don't know in which way I can use $.ajax
.
Could you please help?
If the method is inherently asynchronous, you cannot call it so that it returns synchronously. That's just outright impossible. See How do I return the response from an asynchronous call? for details.
Of course you can!
Notice that
someMethod
is now asynchronous as well, so if you need to pass any results from it then you'd need to use a callback there as well.