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?

1

1 Answer 1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.