| Author |
Sequence of steps executed in Ajax call
|
Kumar Raja
Ranch Hand
Joined: Mar 18, 2010
Posts: 458
|
|
Hi All,
I'm very new to Ajax and started with a tutorial given at http://www.ibm.com/developerworks/library/j-ajax1/. . But instead of working on Shopping cart example, I replaced that with a TimeServlet that returns the current time. Servlet is working fine and I'm pasting any details about it here.
But below are my ajax calls
I'm calling getTime() function on onload event of the webpage. I'm getting response properly as expected. To trace the call, I used alert statement displaying the request.readyState and what I noticed in getReadyStateHandler() function, it get started with readyState as 1 and does not go in sequence like 1, 2, 3, 4 , instead I see 1, 2, 4 and 3.. and some times 1,2,3, 4,4 .. Is there any error in the way I'm making the ajax calls. Or I don't have to worry about the calls. Please advise.
|
Regards
KumarRaja
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
Using alert for debugging can lead to some weird timing issues.
You really should use console.log() and log to the JavaScript console. With Firefox, you can use Firebug. Chrome and IE8+ have the console built in.
Eric
|
 |
Kumar Raja
Ranch Hand
Joined: Mar 18, 2010
Posts: 458
|
|
Hmm, Thanks Eric. I will try console logging instead of Alerts.
As a side note to this question, I was also browsing Log4Javascript library. Is that worth using ?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
I have not used it.
Eric
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56528
|
|
|
I'd try using the built-in logging first and bring in bigger guns only if necessary.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Sequence of steps executed in Ajax call
|
|
|