XMLHttp小手冊,原生ajax參考手冊

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   使用   java   

個人做java ee開發,在一般的公司裡上班,做的是一般的網站。

1.如果經常使用jquery等架構進行非同步呼叫,最主要的不是瞭解jquery怎麼用,而是瞭解http協議。

2.為了瞭解http協議,可以使用Firefox的控制台F12,Google的控制台F12查看responseHeader,requestHeader.在IE下,可以使用HttpWatch Professional這個工具。

3.如果要系統瞭解原生的ajax請求,可以訪問網站 xmlHttp小手冊 http://fireyy.com/doc/xmlhttp/xmlhttprequest.html

 

<html><head><script type="text/javascript">    var xmlHttp;    function loadXMLDoc(url){        xmlHttp=null;        if(window.XMLHttpRequest){            //IE7,FireFox,Opear,等瀏覽器            xmlHttp=new XMLHttpRequest();        }else if(window.ActiveXObject){        //IE5,IE6瀏覽器            xmlHttp=new ActiveXObject("Microsoft.XMLHttp");        }        if(xmlHttp!=null){            xmlHttp.onreadystatechange=state_Change;            xmlHttp.open("GET",url,true);            xmlHttp.send(null);        }else{            alert("您的瀏覽器不支援xmlHttp");        }    }        //狀態變化時調用的回呼函數    function state_Change(){        //4--載入完畢        if(xmlHttp.readyState==4){            //200 --OK            if(xmlHttp.status==200){                document.getElmentById(‘‘).innerHTML=xmlHttp.status;                doucment.getElmentById().innerHTML=XMLHttp.statusText;                doucment.getElmentById().innerHTML=xmlHttp.responseText;            }else{                alert(‘取回資料XML錯誤 狀態為: ‘+xmlHttp.statusText);            }        }    }    </script></head><body>    <h2>使用HttpRequest對象</h2>        <p><b>Status:</b>    <span id="A1"></span>    </p>        <p><b>Status text:</b>    <span id="A2"></span>    </p>        <p><b>Response:</b>    <br/><span id="A3"></span>    </p>        <button onclick="loadXMLDoc(‘http://www.w3school.com.cn/example/xdom/note.xml‘)">Get XML</button></body>

XMLHttp小手冊,原生ajax參考手冊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.