| onreadystatechange | ใช้กำหนดให้ function ที่กำหนด ทำหน้าที่ตรวจสอบสถานะการทำงานของการ request |
|---|
property:onreadystatechange = function;
return type:void
content:ใช้กำหนดให้ function ที่กำหนด ทำหน้าที่ตรวจสอบสถานะการทำงานของการ request และสิ่งที่จะเกิดขึ้นหลังจากการ request ( ทั้งกรณีที่ request สำเร็จ และไม่สำเร็จ )
example:var xhr = new XMLHttpRequest (); xhr.open ( "GET", "localhost/test.php?param=value" ); xhr.onreadystatechange = responseXHR; function responseXHR() { if ( xhr.readyState == 4 ) { alert ( "request success" ); if ( xhr.status == 200 ) { alert ( "complete" ); } } }