Results 1 to 10 of 10

Thread: AJAX responseText value on a Timeout?

  1. #1
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default AJAX responseText value on a Timeout?

    If a connection times out, what will responseText be? What it was before or null?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Null, I believe. It shouldn't matter because you should have checked the readyState already.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Yes Twey is absolutely correct there is no need to use the responseText as you will be checking the readyState and status before accessing the responseText.

  4. #4
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    Well on w3schools it didn't say what number it was for timeout.

  5. #5
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    timeout is
    Code:
    ready.status = 408
    http://dirtybooger.com/error-codes.php#Connection

  6. #6
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    What is ready? The AJAX variable?

  7. #7
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by ??? View Post
    What is ready? The AJAX variable?
    yes, "ready" is the variable that you assign to the AJAX HTTPObject initiation sorry about the confusion

  8. #8
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    Thanks, but does onreadysatechange change when that does? And if not, is ready state 4 when it's timed out?

  9. #9
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by ??? View Post
    Thanks, but does onreadysatechange change when that does? And if not, is ready state 4 when it's timed out?
    there is a process to any programming, and AJAX is no different. I / most programmers have a library of codes to use rather then trying to "reinvent the wheel".

    at the top of my library javascript file i have the HTTPObject identifier. this checks if the httpobject is available and enabled. and anything that I do, will pass through this function first.

    you then need to define what you want to do... in your instance you are wanting to write something out onto the screen. well before you do that you need to know what to write and how / where to write it to.. so you call your function according, and you define a request / ready / whatever variable you wish to use.. and you make that the httpobject function

    Code:
    var request = getHTTPObject()
    or whatever you called that function.

    now when you call this in your script you there are various stages to the call... send, process, receive, done.. you dont want to concern yourself with anything but
    Code:
    request.readyState=4
    from there you will need to check what status message it is returning, whether it be a valid page or unvalid... in this case you want the timeout status so
    Code:
     request.status = 408
    then yo do whatever you wish to do from there


    Code:
    function getHTTPObject() 
    {
     var ready = false  // default to false
     // check http object if valid return true
     // becareful of IE and microsoft!
    }
    
    function getSomething(file) {
       var ready = getHTTPObject();
        if(ready.readyState = 4) 
       {
            if(ready.status == 408)
            {
                 // page timed out do something
            }
            else if(ready.status = 200)
            {
                 // valid page call do something
            }
            else if( etcetc)
            {
                 // do something else
            }
        }
    }
    i hope that helps

  10. #10
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    Thanks.

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
  •