File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sequence of steps executed in Ajax call

 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 547
2
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not used it.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd try using the built-in logging first and bring in bigger guns only if necessary.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic