Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AJAX lag issue

 
Bill Clar
Ranch Hand
Posts: 163
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the most peculiar AJAX/Javascript problem. I'm having difficulty retrieving the value returned from an AJAX request.

I'm assigning the XMLHttpRequest.responseText value to a simple text field. When I try to retrieve this very field, the info
is undefined. I can see it populated on the screen in the text field, but I cannot retrieve it.

If I call an alert() on the field, it's undefined. If I call alert() a second time, the value appears.

Does AJAX have some sort of lag that prevents or hinders the user from retrieving the XMLHttpRequest.responseText data? Do I need to do something more
than ensure the state and status of the AJAX object are successful?

Thanks,

Bill Clar


 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are making an asynchronous request, not a synchronous one.

You make the Ajax call and it continues on its way, it does not wait til it comes back.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64837
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, you can't check the value before it gets set and expect it to be there
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic