wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes simultaneous ajax requests 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 "simultaneous ajax requests" Watch "simultaneous ajax requests" New topic
Author

simultaneous ajax requests

krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
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


have a great day,
krishna prasad
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jul 25, 2006
Posts: 158
thankyou eric,
You are right! global variable is the issue.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Libraries such as jQuery and Prototype make it easy to create Ajax requests without the need for global variables.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: simultaneous ajax requests