Asynchronous vs Synchronous Ajax

Synchronous – Script stops and waits for the server to send back a reply before continuing. There are some situations where Synchronous Ajax is mandatory.

In standard Web applications, the interaction between the customer and the server is synchronous. This means that one has to happen after the other. If a customer clicks a link, the request is sent to the server, which then sends the results back.

Because of the danger of a request getting lost and hanging the browser, synchronous javascript isn’t recommended for anything outside of (onbefore)unload event handlers, but if you need to hear back from the server before you can allow the user to navigate away from the page, synchronous Javascript isn’t just your best option.



Asynchronous – Where the script allows the page to continue to be processed and will handle the reply if and when it arrives. If anything goes wrong in the request and/or transfer of the file, your program still has the ability to recognize the problem and recover from it.
Processing asynchronously avoids the delay while the retrieval from the server is taking place because your visitor can continue to interact with the web page and the requested information will be processed with the response updating the page as and when it arrives.





<<Previous <<   || Index ||   >>Next >>









14 comments:

  1. thanks.. It's working for me.

    ReplyDelete
  2. Java Lover @ 135July 17, 2014 at 1:14 AM

    Great Post!!

    ReplyDelete
  3. Viswanathan SaravananSeptember 9, 2014 at 1:36 PM

    Hi dinesh, how action error messages are captured without in employee.jsp?

    ReplyDelete
  4. Another option is we can use simple error map and return to view end with error message.

    ReplyDelete
  5. Hi Dinesh,
    To make it very correct please add method="addEmployee" which is missing in

    ReplyDelete
  6. Thanks Viswanathan for this correction.

    ReplyDelete
  7. Nguyễn Văn SơnJanuary 22, 2015 at 2:54 AM

    Thank you! Your post's amazing!

    ReplyDelete
  8. Bruno Maia SerralheiroFebruary 5, 2015 at 1:31 PM

    Dear Dinnesh, if you still get the same exception after being careful with the case sensitiveness, what might be the problem?

    ReplyDelete
  9. Bruno Maia SerralheiroFebruary 5, 2015 at 2:25 PM

    I would like to share my experience about this issue: for @Entity and @Table avoid hibernate annotation.

    Use JPA (javax.persistence) instead:
    import javax.persistence.Entity;
    import javax.persistence.Table;

    It took me a day to see this silly mistake one time.

    Congratulations for this post.

    Best Regards!

    ReplyDelete