PDA

View Full Version : AJAX responseText value on a Timeout?



???
08-23-2007, 03:14 AM
If a connection times out, what will responseText be? What it was before or null?

Twey
08-23-2007, 07:38 AM
Null, I believe. It shouldn't matter because you should have checked the readyState already.

codeexploiter
08-23-2007, 09:34 AM
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.

???
08-23-2007, 02:52 PM
Well on w3schools it didn't say what number it was for timeout.

boogyman
08-23-2007, 03:50 PM
timeout is


ready.status = 408

http://dirtybooger.com/error-codes.php#Connection

???
08-24-2007, 03:45 AM
What is ready? The AJAX variable?

boogyman
08-24-2007, 02:51 PM
What is ready? The AJAX variable?

yes, "ready" is the variable that you assign to the AJAX HTTPObject initiation sorry about the confusion

???
08-25-2007, 03:52 AM
Thanks, but does onreadysatechange change when that does? And if not, is ready state 4 when it's timed out?

boogyman
08-28-2007, 12:48 AM
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



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

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

request.status = 408
then yo do whatever you wish to do from there




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

???
08-31-2007, 02:54 PM
Thanks.