This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simultaneous ajax requests

 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good day,
i send an ajax request. before i get the response for that request, i make another request. i receive the response of the second, but not the first.
so to solve this problem, i have called the javascript function that contains the second ajax request, from the response of first request. by this way, we could avoid the second request being made, before the first response.

sequence of steps that created problem

1. ajaxrequest1 -------------->server
2. ajaxrequest2 -------------->server
3. ajaxresponse2 <-------------server


end

my solution

1. ajaxrequest1 -------------->server
2. ajaxresponse1(call javascript function that makes 2nd request) <-------------server
3. ajaxrequest2 -------------->server
4. ajaxresponse2 <-------------server


end

but this somehow, i think, limits ajax's power. is there any other solution.

have a great day,
krishna prasad g
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing your code sounds like you are using global variables to hold the request object. When you make the second request you write over the first.

Eric
 
krishna prasad gunasekaran
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankyou eric,
You are right! global variable is the issue.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Libraries such as jQuery and Prototype make it easy to create Ajax requests without the need for global variables.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic