property:readyState;
return type:number
content:ใช้คืนค่าสถานะการทำงานปัจจุบันของการ request
example:var xhr = new XMLHttpRequest ();
xhr.open ( "POST", "localhost/test.php" );
xhr.onreadystatechange = responseXHR;
xhr.setRequestHeader ( "Content-type", application/x-www-form-urlencoded" );
xhr.send ( "name=bamboo&pass=labcode" );
function responseXHR()
{
if ( xhr.readyState == 4 )
{
alert ( "request success" );
}
}
comment:ถ้าคืนค่า 0 คือยังไม่เริ่มทำงาน ( ยังไม่ได้เริ่มเรียกใช้ open() )
ถ้าคืนค่า 1 คือกำลังโอนถ่ายข้อมล ( ประมวลผลใน open() อยู่ )
ถ้าคืนค่า 2 คือโอนถ่ายข้อมูลเสร็จแล้ว ( ประมวลผลใน send() อยู่ )
ถ้าคืนค่า 3 คือกำลังทำงานอยู่ ( server กำลัง response กลับมา )
ถ้าคืนค่า 4 คือการทำงานเสร็จสมบูรณ์