Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > ajax

PJBLOG中用到的ajaxjs.几个简单的函数

来源:中文源码网    浏览:116 次    日期:2024-05-03 06:33:31
【下载文档:  PJBLOG中用到的ajaxjs.几个简单的函数.txt 】


PJBLOG中用到的ajaxjs.几个简单的函数
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); } } } }

相关内容