The Way to Programming
The Way to Programming
please read this :
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests#Synchronous_request
and:
http://api.jquery.com/jquery.ajax/
it is not the synchronous call that is deprecated. It is the use of the Deferred object’s API with a synchronous call which is deprecated. And that only makes sense – if you have a blocking call, you do not need to trap an event when the call completes. The “handler” will be the line of code after the call.
Also, the $.ajax() call defaults to an asynchronous call. If no other config is done, then every call will be asynchronous. That also makes sense – synchronous calls are needed only in specific situations. My assertion is that this is one of them. If the script requires the return from FraudAlert() before it can continue, then it needs to wait on that return. I.e., it needs a synchronous call that blocks execution until is complete.
The OP’s pattern is not using the Deferred API. I still maintain that if the application needs to wait on a response, it needs to implement a synchronous call.. that’s the point of synchronous vs asynchronous.
Sign in to your account