首页 > 语言 > JavaScript > 正文

javascript工具库代码

2024-05-06 14:22:15
字体:
来源:转载
供稿:网友
代码如下:
/*
 *YYJ.js 主要提供后台应用方法
 *目前有Ajax、addLoadEvent、deleteAll、getByClass、$C(=getByClass)、$、yyjtable、setCss、getCss、iaArray等方法。最后面还提供了一个
 *可实例化的方法YYJ.tick用来计算脚本运行时间
 *版本0.1    --tianyi    yyj
 */
 var YYJ=function(){
     var UniqueInstance;
     function constrotor(){
         return {
             //ajax方法
             Ajax:function(method,url,data,success,fail){
                 var isget=method.toLowerCase()=="get";
                 var xmlhttp=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");
                 xmlhttp.open(method,url,true);
                 if(!isget)xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                 xmlhttp.onreadystatechange=function(){
                         if(xmlhttp.readyState==4){
                             if(xmlhttp.status==200){
                                 if(success)success(xmlhttp);
                             }else{
                                 if(fail)fail(xmlhttp);
                             }
                         }
                 };
                 xmlhttp.send(isget?null:data);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选