How to set time limit for loading the result?

Hi all,
I have a form,
in which i used to display the select box, at the time of loading the page…
based on the selection of this, i want to populate another select box by sending the query to the server…(this is by using ajax).

But, i want to check the time to display the second select box, and first selections was made…
The diff b/w these process will reach say 30 sec, it will show the message?

how to implement it…
or is there any other way to do this?

You’d have to use Javascript for this to be accurate (PHP can only count the time in operation, not in transit).

Thanking you,

what is the code, i want to write? and where it should be.
Because, i don’t know much about javascript?

I cant give specifics because i’m not sure how i’d do it exactly, but the logic would be something like… (in pseudocode)


var timerflag = false;
var count = 0;

function AJAXCall() {
 ......
 //All your normal AJAX stuff goes here
 count = 0;
 timerflag = true;
 startTimer();
}

function startTimer() {
  //Implement counter to count to 30, if it reaches 30, stop timer and output message
  //Counter should check timerflag to see if it needs to stop early.
}

function AJAXReceiveHandler() {
  .......
  //Normal AJAX handler to receive data
  timerflag = false;
}