欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ajax基本通用代碼示例

 更新時間:2016年05月30日 09:40:53   作者:keyunq  
這篇文章主要介紹了ajax基本通用代碼,簡單分析了常用ajax的定義與使用技巧,需要的朋友可以參考下

本文實例講述了ajax基本通用代碼。分享給大家供大家參考,具體如下:

<html>
<head>
<script type="text/JavaScript">
var xmlhttp
function loadXMLDoc(url)
{
 // code for Mozilla, etc.
 if (window.XMLHttpRequest)
 {
 xmlhttp=new XMLHttpRequest()
 xmlhttp.onreadystatechange=state_Change
 xmlhttp.open("GET",url,true)
 xmlhttp.send(null)
 }
 // code for IE
 else if (window.ActiveXObject)
 {
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  if (xmlhttp)
  {
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send()
  }
 }
}
function state_Change()
{
 // if xmlhttp shows "loaded"
 if (xmlhttp.readyState==4)
 {
 // if "OK"
 if (xmlhttp.status==200)
 {
 document.getElementById('T1').innerHTML=xmlhttp.responseText
 }
 else
 {
 alert("Problem retrieving data:" + xmlhttp.statusText)
 }
 }
}
</script>
</head>
<body onload="loadXMLDoc('test_xmlhttp.txt')">
<div id="T1" style="border:1px solid black;height:40;width:300"></div><br />
<button onclick="loadXMLDoc('test_xmlhttp2.txt')">Click</button>
</body>
</html>

更多關(guān)于ajax相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jquery中Ajax用法總結(jié)》、《JavaScript中ajax操作技巧總結(jié)》、《PHP+ajax技巧與應(yīng)用小結(jié)》及《asp.net ajax技巧總結(jié)專題》。

希望本文所述對大家ajax程序設(shè)計有所幫助。

相關(guān)文章

最新評論