生活随笔
收集整理的這篇文章主要介紹了
Ajax的使用体验
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Ajax其實很簡單,我現在就將用Ajax技術開發時用的方法和步聚分享給大家
?
?function?createXMLHttpRequest() ?{ ???if(window.ActiveXObject){ ??????????try{ ?????????xmlhttp=new?ActiveXObject("Msxml2.XMLHTTP");? ?????}catch(e){ ?????????try{ ?????????????xmlhttp=new?ActiveXObject("Microsoft.XMLHTTP"); ?????????}catch(e){?} ?????}? ?}else?if(window.XMLHttpRequest){ ??????????xmlhttp=new?XMLHttpRequest(); ?????} ?if(!xmlhttp){ ?????xmlhttp=false; ?????alert("無法建立?Ajax?請求對象,你的瀏覽器版本太低,建議升級你的瀏覽器."); ??????????} ??var?pubdiv=""; ?function?AjaxGetContent(url,divobj) ?{ ???pubdiv=divobj; ???createXMLHttpRequest(); ???document.getElementById(divobj).innerHTML="正在載入..."; ???xmlhttp.onreadystatechange=ResultAjaxGetContent;????xmlhttp.open("post",url,true); ???xmlhttp.send(null) ?} ??function?ResultAjaxGetContent() ?{ ???if?(xmlhttp.readyState==4) ???{ ?????if?(xmlhttp.status==200) ?????{ ???????document.getElementById(pubdiv).innerHTML=xmlhttp.responseText; ??????}?????? ????} ?} ??如 ??function?AjaxShowCart() ?{ ???var?url="cart.asp?userid=8"; ???AjaxGetContent(url,"div_cart") ?} ?? ?
轉載于:https://blog.51cto.com/hlhcto/390408
總結
以上是生活随笔為你收集整理的Ajax的使用体验的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。