• In Ajax return how to value from nested asynchronous function ?

    Gallard Member

    In Ajax return how to value from nested asynchronous function ?

  • SapnaVishwas Member

    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/

  • Adan Member

    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.

  • SapnaVishwas Member

    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.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
en_USEnglish