aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Sequence of steps executed in Ajax call 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 "Sequence of steps executed in Ajax call" Watch "Sequence of steps executed in Ajax call" New topic
Author

Sequence of steps executed in Ajax call

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

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: 15376
    
    6
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: 518
    
    2

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: 15376
    
    6
I have not used it.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

I'd try using the built-in logging first and bring in bigger guns only if necessary.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sequence of steps executed in Ajax call