Ajax. Introduction

568 views
531 views

Published on

Introduction to ajax

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
568
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ajax. Introduction

  1. 1. Ajax Основы Алексей Бованенко
  2. 2. Объект • ActiveXObject(“Microsoft.XMLHTTP”) • XMLHttpRequest
  3. 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. 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. 5. Получение данных • if(xmlhttp.readyState==4){ if(xmlhttp.status==200){ try{ var response=xmlhttp.responseText; d.innerHTML=response; }catch(e){ alert("answer failed"); } } }
  6. 6. Конец Спасибо за внимание e-mail: a.bovanenko@gmail.com

×