473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Calling Ajax function a second time before it finishes.

I have an html table where each row has a column with the name of a workshop. The name of a workshop is a link that 'onclick' calls the function
GetDescription(WorkshopID).

The function is implemented as an Ajax call and works with no problem. On the server the WorkshopID is used to make a MySQL query to get the description of the workshop.

My question is:
"What if a quick user clicks on a workshop name and then another workshop name before the first call completes?"
EVerything works so well (and quick) that I don't know how to test this situation.

Did I write my ajax code correctly?

The ajax call is the usual asynchronous one - to save space I just summarize it below.

Thank you,
Joe

Expand|Select|Wrap|Line Numbers
  1. function GetDescription(WorkshopID
  2. {
  3.   var x = getXMLHttpRequestObject();  // the usual call here
  4.  
  5.   // test for failure to get request object
  6.   if(!x)
  7.   {
  8.     alert("Ajax Failure");
  9.   }
  10.  
  11.   x.onreadystatechange = function()
  12.   {
  13.     if(x.readyState != 4)
  14.     {
  15.       return;
  16.     }
  17.  
  18.     var description = x.responseText;
  19.  
  20.     alert(description); // Show workshop description
  21.   };
  22.   x.open("POST", ..., true);
  23.   x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  24.   x.send(...); 
  25. }
Aug 20 '13 #1
1 1321
Rabbit
12,516 Expert Mod 8TB
If you want to test the situation, put a pause in the server side code.
Aug 20 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ken | last post by:
hello, I would to know if it is possible to call an object in a function within a class. Meaning , In a class, A function X calling onto a function Y, and function Y we want one of the two...
2
by: Joe | last post by:
I have 3 functions: ClientInfoA is doing something ClientInfoB is doing something SelectFunction2Run is a function to determine which function needed to run based on the value of the variable...
4
by: gf | last post by:
<script> function testme(testvar) { if (testvar=='1') { alert('testvar=1'); document.open(); document.write('This is just some text<br /><br />"); document.write('<a...
13
by: ukrbend | last post by:
I'm new to Javascript and to html and am trying to make the following code snippet work but it doesn't. It refuses to call the getPage() function and I always get a 404 error. I know the code is...
5
by: jamo | last post by:
Hi all, can anyone help with this problem. I want to call an Ajax function from a list menu *onchange*, my javascript is not good. Code below: Menu: <select name="menu1"...
1
by: shivendravikramsingh | last post by:
hello friends, actually i have a problem in using conditional statement in ajax function i m tring to describe my problem properly,what i want when i select a value form a combo its vlue is passed...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
0
by: Med | last post by:
Hi, I have two dropDown lists ddlCars and ddlModels. ddlCars AutoPostBack="true" to populate the ddlModels when a car is selected. If the page is not valid (i.e. user left a mandatory textbox...
17
by: Shalini Bhalla | last post by:
i have 2 tables bank master and branch details having bankcode as a common feild . i have designed a form in which i am filtering branches according to a particular bank code using ajax ,...
4
by: BaseballGraphs | last post by:
Hello, I am trying to update data on my webpage using AJAX. The idea is when a user clicks a checkbox the data will be updated. This is the code that I have so far: <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.