
Originally Posted by
???
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
Bookmarks