method:send ( string );
return type:void
content:ใช้กำหนดค่าข้อมูลที่จะส่งไปยัง page ปลายทาง
โดยมีรูปแบบคือ ชื่อตัวแปร=ค่าตัวแปร&ชื่อตัวแปร=ค่าตัวแปร&ชื่อ...
example:var xhr = new XMLHttpRequest ();
xhr.open ( "GET", "localhost/test.php?param=value" );
xhr.onreadystatechange = responseXHR;
xhr.send ( null );
function responseXHR()
{
if ( xhr.readyState == 4 )
{
alert ( "request success" );
if ( xhr.status == 200 )
{
alert ( "complete" );
}
}
}
comment:ถ้าเป็นการ request แบบ GET ให้ส่ง send เป็น null
ถ้าเป็นการ request แบบ POST ให้ส่ง send ตามรูปแบบที่กำหนด และต้องเพิ่มคำสั่งคือ
xhr.setRequestHeader ( "Content-type", application/x-www-form-urlencoded" );