wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Sending multiple requests through AJAX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Sending multiple requests through AJAX" Watch "Sending multiple requests through AJAX" New topic
Author

Sending multiple requests through AJAX

Sudipta Laha
Ranch Hand

Joined: Aug 23, 2010
Posts: 49
Hi,

I am new to AJAX.

I am facing some problem. Help or suggestion in this regards is highly appreciated.

I have to add row to a table on click of a button(click of button i call b()).

below is the code i am using


In the servlet i am making the thread to sleep for 1000 milli seconds.
Now when i click on the button 3 times, three rows gets created.
For the first two rows its shows js error(wen the servlet sends the response) and for the last row with index=2 it works properly and gives alert also. Data is not populated for the 1st two rows but for the 3rd row it comes up fine.

I am using struts2 framework in my application.

Can you please suggest how to handle this situation and why this is happening.


Regards,
Sudipta Kumar Laha
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are using a global variable to hold the Ajax requests. Each time you call it, you override the last call.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

The vast majority of the senior web developers that post here know better than to use raw Ajax. There are just too many subtleties to keep track of. Follow their lead and use on of the popular javaScript libraries (jQuery, Dojo, Prototype) to do your Ajax for you. You will be a happier man for it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sudipta Laha
Ranch Hand

Joined: Aug 23, 2010
Posts: 49
Hi,

Thanks Eric .. Its worked for me with your suggestion. [ ]

Thanks Bear Bibeault ... will take your suggestion and will try to familier with the new libaries. []
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending multiple requests through AJAX