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

AJAX Issue - Messages got lost...

 
Ram Kumar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having this issue when calling two AJAX calls from my code.

One is time to run every 3 seconds using windows.setInterval (for 10 seconds) and I call a method which calls a jsp page.

I have another ajax call that calls another servlet which is called manually by user input using onClick.

The first one calls a jsp to fetch a html response which it uses to build the client html (div.innerHTMl += response from ajax call) this is a for a import operation.

The second call (through onclick) basically calls the servlet to cancel the import operation.

Whenever I call the 2nd one the first is also called. I see the time stamps of calls from the first call to java frome the first call consistently happening every 10 seconds. When I do the onclick and call another method in java script to do the 2nd ajax call the first one seems to be called as well. I checked whether I am calling the first method in the 2nd and I didn't.

I dont know what is causing this behaviour. Because, of that the messages to be obtained by the first call gets lost somehow).

I did create my xmlreq obj using new ActiveXObject("Microsoft.XMLHTTP"), is the xmlhttp req object commonly used by all AJAX calls?

Please let me know.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you are using global variables. Without seeing how you are making requests, I can not give you an exact answer.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both Eric and I have said it again and again. You can save yourself a ton of headaches by letting a library such as jQuery or Prototype handle Ajax calls for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic