3

Assuming I start a looping function via ajax that waits a response from a device (in this case a barcode reader), I need to do an other ajax call if a "Back" button is pressed (while the first function is still running). How could it be done? Using abort don't work because server is still inside looping cycle. Any idea?

  • 1
    So you're saying that the browser uses ajax to request data from a barcode reader by proxy, but if the user presses the back button you want to both abort the request __and__ the python code that retrieves the barcode reader data? You want the second request to tell python to stop the action from the first request? – benastan May 09 '12 at 15:59
  • @gdoron AJAX is async - it shouldn't be a problem. A callback function is waiting on client side, shouldn't effect server side. (Like you wrote in your answer). So if it's so simple, what's the question? I'm assuming the asker tried and it didn't work. – JNF May 09 '12 at 16:01
  • @JNF. Ohhh, now I got your comment, sorry, I'm deleting it. – gdoron May 09 '12 at 16:05
  • Apparently, I'm a mind reader. http://stackoverflow.com/questions/10520954/different-ajax-calls-with-polling-cycle – benastan May 09 '12 at 17:22

1 Answers1

1

Just send another ajax request, you can have multiple ajax request at the same time.

sendFirstAjax();
sendSecondAjax(); // doesn't have to wait the first ajax to complete.
gdoron
  • 147,333
  • 58
  • 291
  • 367