AJAX源码

//伪AJAX
//==============================================显示所有信息=========================================


var xmlHttp;

function createXMLHttpRequest()
{
 if(window.ActiveXObject)
 {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 else if(window.XMLHttpRequest)
 {
  xmlHttp=new XMLHttpRequest();
 }
}

function createXMLHttpRequest1()
{
 if(window.ActiveXObject)
 {
  xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
 }
 else if(window.XMLHttpRequest)
 {
  xmlHttp1=new XMLHttpRequest();
 }
}
/*function test1()
{
 alert('test')
}
var test=function(){alert('test')}
*/

function clearInput()
{
 argsLen=arguments.length
 for(var i=0;i<argsLen;i++)
 {
  $(arguments[i]).value="";
 }
}
function getData(page)

 //alert("1")
 createXMLHttpRequest();
 url="ajax/showall.asp?page="+page
 //alert("2")
 xmlHttp.open("GET",url,true);
 //alert("3")
 xmlHttp.onreadystatechange=callback;
 //alert("4")
 xmlHttp.send(null);
 //alert("5")
}

//==============================================搜索================================================

function getSearchResult(queryurl,page)

 //alert(queryurl)
 createXMLHttpRequest();
 url="ajax/search.asp?"+queryurl+"&page="+page
 xmlHttp.open("GET",url,true);
 xmlHttp.onreadystatechange=callback;
 xmlHttp.send(null);
}

//=================================================日历=================================================
function showCalender(year,month,type)

 createXMLHttpRequest1();
 if (type=='b')
 theurl="ajax/lunarcal.asp?y="+year+"&m="+month;
 else
 theurl="ajax/calendar.asp?y="+year+"&m="+month;
 //alert(theurl)
 xmlHttp1.open("GET",theurl,true);
 xmlHttp1.onreadystatechange=callcalender;
 xmlHttp1.send(null);
}


function callcalender()
{
 //alert('callcalender is ok')
 if(xmlHttp1.readyState==4)
  {//alert('callcalender1 is ok')
   if(xmlHttp1.status==200)
    {//alert('callcalender2 is ok')
     $('showcal').innerHTML=xmlHttp1.responseText
    }
   
  }
}
//====================================================================================================
function callback()
{
 //alert('callback is ok')
 if(xmlHttp.readyState==4)
  {//alert('callback1 is ok')
   if(xmlHttp.status==200)
    {
     $('showdata').innerHTML=xmlHttp.responseText
    }
   
  }
}

function showInfo(id,areaid)
{
 createXMLHttpRequest();
 url="ajax/showinfo.asp?id="+id
 //alert("2")
 xmlHttp.open("GET",url,true);
 //alert("3")
 this.areaid=areaid
 xmlHttp.onreadystatechange=callinfo;
 //alert("4")
 xmlHttp.send(null);
}

function callinfo(areaid)
{
 areaid=this.areaid
 //alert('callback is ok')
 if(xmlHttp.readyState==4)
  {//alert('callback1 is ok')
   if(xmlHttp.status==200)
    {
     $(areaid).innerHTML=xmlHttp.responseText
    }
   
  }
}

function showDetailInfo(id,areaid){

var ShowBtn=$("showBtn"+id)
var str1=ShowBtn.src.substring(ShowBtn.src.lastIndexOf("/")+1)
if  (str1=="sign_sub.gif")
{
//Realinfo.style.display="none";
ShowBtn.src="img/sign_plus.gif";
$(areaid).innerHTML=""
$(areaid).style.display="none"
}
else{
//Realinfo.style.display="";
ShowBtn.src="img/sign_sub.gif";
showInfo(id,areaid)
$(areaid).style.display=""
}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值