0

Currently I have a setInterval javascript function which calls an ajax function to call a php script. This php script is a server that is waiting for a request from a client being run by another program. The client will send a String whenever there are changes made and this string is to be echoed back through ajax.

setInterval(function(){getTopo()}, 2000);

getTopo() is a $.ajax calling server.php

I want to terminate the server.php file if there is no reply within 2 secs before running getTopo() again.

Else can I output through ajax an echo in the php's while loop?

Jeff Lambert
  • 24,395
  • 4
  • 69
  • 96
MerC
  • 323
  • 1
  • 5
  • 19

1 Answers1

0

Save the interval into a variable, for example:

var t = setInterval(getTopo, 2000)

And use clearInterval(t) to stop querying the server.

From here, you should create your own code to satisfy your needs.

Novak
  • 2,760
  • 9
  • 42
  • 63