• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sequence of steps executed in Ajax call

 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not used it.

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd try using the built-in logging first and bring in bigger guns only if necessary.
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic