Code Snippet
function GetTasks()
{
//创建XMLHttpRequest对象
var xmlhttp
try{
xmlhttp = new XMLHttpRequest();
}catch(e){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
//创建请求结果处理程序
xmlhttp.onreadystatechange = function(){
if(4 == xmlhttp.readyState){
if(200 == xmlhttp.status){
var rt = xmlhttp.responseText;
if (rt.substr(0,4)!="")
{
document.getElementById('xxts').innerHTML=rt;
}
else
{
document.getElementById('xxts').innerHTML="正在获取信息中....";
}
}else{
document.getElementById('xxts').innerHTML="获取任务信息中...";
}
}
}
//打开连接,true代表异步提交
xmlhttp.open("post","Tasks_AjaxGet.aspx",true);
//当方法为POST时需要设置HTTP头
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//发送数据
xmlhttp.send(null);
}