Help coderanch get a
new server
by contributing to the fundraiser
  • 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

AJAX Issue - Messages got lost...

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67750
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
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.
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic