Mais conteúdo relacionado
Mais de Alexey Bovanenko (20)
Ajax. Introduction
- 2. Объект
• ActiveXObject(“Microsoft.XMLHTTP”)
• XMLHttpRequest
- 3. Создание XMLHTTP объекта
• try{
xmlhttp=new XMLHttpRequest();
}catch(e){
var xmlarray=new Array("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");
for(var i=0;i<xmlarray.length;++i){
try{ xmlhttp=new ActiveXObject(xmlarray[i]); }catch(e){}}}
- 4. Отправка запроса
• try{
xmlhttp.open("GET","http://localhost/~alexei/test/getdata.php?
d="+text,true);
xmlhttp.onreadystatechange=handler1;
xmlhttp.send(null);
}catch(e){
alert("send failed");
}
- 5. Получение данных
• if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
try{
var response=xmlhttp.responseText;
d.innerHTML=response;
}catch(e){
alert("answer failed");
} } }