<script>
var xmlHttp;
---------------------------------------------------------------------------------------
function createXMLHttpRequest()
{
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
}
-------------------------------在创建Ajax对象的时候采用以上部分就行--------------------
function startRequest()
{
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
var id=document.getElementById("Text1").value;
var url="Default2.aspx?id="+id;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
var valueText = xmlHttp.responseText;
alert(valueText);
}
}
}
</script>
网友评论