Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

AJAX Data Return - Handling Out of Order Responses

Posted on 2006-05-24
2
Medium Priority
?
421 Views
Last Modified: 2011-09-20
Ok Here's the question:  I have a data display page that takes a set of criteria and returns data from a database based on that search criteria.  My problem is that if I make a request that will take 15 seconds to return, then realize it was a mistake and make a request that only takes 1 second to return I hit an overwriting issue.

The 1 second request will complete first and return the data it was supposed to, but then the 15 second request returns and improperly overwrites all of the data from the 1 second request.  What is the best way to handle this to make sure I'm not allowing out of order returns to squash the data I really want?

It's all Javascript based so please keep reponses to Javascript.  Thanks!
0
Comment
Question by:skacore
  • 2
2 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 16754047
One common method to deal with this is sending serial numbers in requests, which get returned with responses.
Store the maximum serial number handled.
When a response gets back to you, ignore it unless it has a higher serial number than the current maximum.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 16755325
Thanks!

Maybe my most points for least effort!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question