SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    You'd have to use Javascript for this to be accurate (PHP can only count the time in operation, not in transit).

  3. #3
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanking you,

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

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    I cant give specifics because i'm not sure how i'd do it exactly, but the logic would be something like... (in pseudocode)

    Code:
    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;
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •