PJBLOG中用到的ajaxjs.幾個(gè)簡(jiǎn)單的函數(shù)
更新時(shí)間:2007年12月01日 21:27:25 作者:
function $(id)
{
return document.getElementById(id);
}
function echo(obj,html)
{
$(obj).innerHTML=html;
}
function fopen(obj)
{
$(obj).style.display="";
}
function fclose(obj)
{
$(obj).style.display="none";
}
function createxmlhttp()
{
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
if (xmlhttp.overrideMimeType) {//設(shè)置MiME類別
xmlhttp.overrideMimeType('text/xml');
}
}
return xmlhttp;
}
function getdata(url,obj1,obj2)
{
var xmlhttp=createxmlhttp();
if(!xmlhttp)
{
alert("你的瀏覽器不支持XMLHTTP??!");
return;
}
xmlhttp.onreadystatechange=requestdata;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
function requestdata()
{
fopen(obj1);
echo(obj1,"正在加載數(shù)據(jù),請(qǐng)稍等......");
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
if(obj1!=obj2){fclose(obj1);};
echo(obj2,xmlhttp.responseText);
}
}
}
}
{
return document.getElementById(id);
}
function echo(obj,html)
{
$(obj).innerHTML=html;
}
function fopen(obj)
{
$(obj).style.display="";
}
function fclose(obj)
{
$(obj).style.display="none";
}
function createxmlhttp()
{
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
if (xmlhttp.overrideMimeType) {//設(shè)置MiME類別
xmlhttp.overrideMimeType('text/xml');
}
}
return xmlhttp;
}
function getdata(url,obj1,obj2)
{
var xmlhttp=createxmlhttp();
if(!xmlhttp)
{
alert("你的瀏覽器不支持XMLHTTP??!");
return;
}
xmlhttp.onreadystatechange=requestdata;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
function requestdata()
{
fopen(obj1);
echo(obj1,"正在加載數(shù)據(jù),請(qǐng)稍等......");
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
if(obj1!=obj2){fclose(obj1);};
echo(obj2,xmlhttp.responseText);
}
}
}
}
相關(guān)文章
通過(guò)Ajax請(qǐng)求動(dòng)態(tài)填充頁(yè)面數(shù)據(jù)的實(shí)例
今天小編就為大家分享一篇通過(guò)Ajax請(qǐng)求動(dòng)態(tài)填充頁(yè)面數(shù)據(jù)的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
ajax傳遞一個(gè)參數(shù)具體實(shí)現(xiàn)
ajax傳遞一個(gè)參數(shù)或多個(gè)參數(shù)在使用過(guò)程中由于特殊需求經(jīng)常會(huì)用到,下面與大家分享下具體的實(shí)現(xiàn)方法,感興趣的朋友可以參考下哈2013-05-05
Ajax實(shí)現(xiàn)彈出式無(wú)刷新城市選擇功能代碼
這篇文章主要介紹了Ajax實(shí)現(xiàn)彈出式無(wú)刷新城市選擇功能代碼,實(shí)例分析了Ajax彈出窗口及無(wú)刷新選擇數(shù)據(jù)項(xiàng)的相關(guān)技巧,需要的朋友可以參考下2015-08-08
原生ajax和iframe框架實(shí)現(xiàn)圖片文件上傳的兩種方式
這篇文章主要為大家詳細(xì)介紹了原生ajax和iframe框架實(shí)現(xiàn)圖片文件上傳的兩種方式,感興趣的小伙伴們可以參考一下2016-04-04
Ajax實(shí)現(xiàn)省市縣三級(jí)聯(lián)動(dòng)
這篇文章主要為大家詳細(xì)介紹了Ajax實(shí)現(xiàn)省市縣三級(jí)聯(lián)動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-03-03

