SitePoint Sponsor

User Tag List

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

    Reload the page, when AJAX engine processes the server response late?

    Hi all,
    I have a page like this,
    Design New Cable

    In this page, i have displayed a select box at the time of loading the page..
    When a user selects any item from this select box, the AJAX engine calls on the select box, the second select box will be displaying based on the selection.

    Now, if the time to load the new select box after selecting the previous select box is more (means when AJAX engine processes the server is taking more time to display the response), i want to display a message or reload the entire page (if network is properly connected) otherwise (if network connection fails, at that time) it will simply display the network connection failed message....

    How to do this..
    Give me some example to do this..

    Thanking you..

  2. #2
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are using jQuery, so you can use its built in function. Add "timeout" parameter to jQuery's ajax request and event to handle errors, then in that event show message. Something like this:
    Code:
    $.ajax({
     .. your usual parameters ...
     'timeout': 20000, /* 20 seconds */
     'error': function(XMLHttpRequest, textStatus, errorThrown) {
        if(textStatus == 'timeout') 
        {
            .... show your timeout message here ...
        }
      }
    });

  3. #3
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply..
    Where should i add this code...
    I dont know much about Ajax and JQuery..

  4. #4
    SitePoint Evangelist venkat6134's Avatar
    Join Date
    Jul 2010
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any other way to do it..
    Help me to solve this problem..

    Thanking you..


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
  •