--1.javascript具体实现AJAX
var xmlHttp;
function createHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function startRequest()
{
var teamID = document.getElementById("H_TeamID");
var reportDate = document.getElementById("H_ReportDate");
var startDate = document.getElementById("H_StartDate");
var endDate = document.getElementById("H_EndDate");
var urlOrPath = "abc.xml";//重点1:这里可以为一个xml文件的路径,或者一个web url
//初始化http request对象
createHttpRequest();
//设置其回调函数
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET",urlOrPath ,true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert( xmlHttp.responseText );
//重点2:这里还可以使用javascript解析返回的xml字符串
}
}
}
--2.html中调用
<input id = "text" type="button" value = "text" οnclick="startRequest()">