您当前位置:主页 > 程序开发 >
 
PJBLOG中用到的ajaxjs.几个简单的函数
日期:2018-12-31 编辑:admin

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) {//设置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,"正在加载数据,请稍等......");
                if(xmlhttp.readyState==4)
                {
                    if(xmlhttp.status==200)
                    {
                        if(obj1!=obj2){fclose(obj1);};
                        echo(obj2,xmlhttp.responseText);

                    }
                }

        }
}

http://www.bkjia.com/AJaxjc/328898.htmlwww.bkjia.comtruehttp://www.bkjia.com/AJaxjc/328898.htmlTechArticlefunction$(id) { returndocument.getElementById(id); } functionecho(obj,html) { $(obj).innerHTML=html; } functionfopen(obj) { $(obj).style.display=""; } functionfclose(obj) { $(obj).s...

本文源自: AG环亚娱乐

上一篇:一款经典的 jQuery Lightbox 灯箱效果,jquerylightbox 下一篇:没有了
 
Copyright © 2005-2016 http://www.tecsquared.com AG环亚娱乐_AG直营网_环亚娱乐AG最佳线路_腾讯体育版权所有 AG环亚娱乐_AG直营网_环亚娱乐AG最佳线路_腾讯体育