• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending multiple requests through AJAX

 
Sudipta Laha
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sudipta Laha
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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. []
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic