標籤: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參考手冊