pjblog发表评论用的ajaxJS.js
程序员文章站
2022-07-02 16:57:21
document.write('
document.write('<div id="loadingg" style="height:65px; width: 200px;position: absolute; z-index:1000;border:3px;solid;text-align:center;sans-serif;color:#000000;background-color:#ffffff;opacity:.7;-moz-opacity:.7;filter: alpha(opacity=75, finishopacity=50, style=1, startx=0, starty=1, finishx=200, finishy=100); display:none;"><br/><font color="#708090"><b>数据正在读取中,请等候...</b></font><br/><img src="images/loading.gif"/></div>')
function showloading()
{
var obj=document.getelementbyid("loadingg")
if (obj.style.display!="")
{
obj.style.left=((document.documentelement.clientwidth-parsefloat (obj.style.width))/2)+document.documentelement.scrollleft+"px";
obj.style.top=((document.documentelement.clientheight-parsefloat (obj.style.height))/2)+document.documentelement.scrolltop+"px";
obj.style.display="";
}else{obj.style.display="none";}
}
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;
}
showloading()
xmlhttp.onreadystatechange=requestdata;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
function requestdata()
{
fopen(obj1);
//echo(obj1,"正在加载数据,请稍等......");
//alert(xmlhttp.readystate)
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
if(obj1!=obj2){fclose(obj1);};
echo(obj2,xmlhttp.responsetext);
showloading()
}
}
}
}
function postdata(url,obj,data)
{ var rnd=math.random()
var xmlhttp=createxmlhttp();
if(!xmlhttp)
{
alert("你的浏览器不支持xmlhttp!!");
return;
}
showloading()
xmlhttp.open("post", url, true);
xmlhttp.onreadystatechange=requestdata;
xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded");
xmlhttp.send(data);
function requestdata()
{
fopen(obj);
echo(obj,"正在提交数据,请稍等......");
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
echo(obj,xmlhttp.responsetext);
reget(rnd);
settimeout("echo('showresult','')",2000);
echo('message','')
showloading()
}
}
}
}
function ltrim(str)
{
if (str.charat(0) == " ")
{
//如果字串左边第一个字符为空格
str = str.slice(1);//将空格从字串中去掉
//这一句也可改成 str = str.substring(1, str.length);
str = ltrim(str); //递归调用
}
return str;
}
//去掉字串右边的空格
function rtrim(str)
{
var ilength;
ilength = str.length;
if (str.charat(ilength - 1) == " ")
{
//如果字串右边第一个字符为空格
str = str.slice(0, ilength - 1);//将空格从字串中去掉
//这一句也可改成 str = str.substring(0, ilength - 1);
str = rtrim(str); //递归调用
}
return str;
}
//去掉字串两边的空格
function trim(str)
{
return ltrim(rtrim(str));
}
function f(obj)
{
return trim(eval("document.ajax_post."+obj+".value"));
//return trim($(obj).value);
}
function savereply()
{
if(f("username")=="")
{
alert("请填写用户名");
return false;
}
if(f("message")=="")
{
alert("内容不可為空");
return false;
}
var validate,password,log_diskey=0,log_disurl=0,log_dissm=0
validate=""
password=""
if(document.ajax_post.log_diskey.checked){
log_diskey=f("log_diskey")
}
if(document.ajax_post.log_disurl.checked){
log_disurl=f("log_disurl")
}
if(document.ajax_post.log_dissm.checked){
log_dissm=f("log_dissm")
}
if((typeof eval(document.ajax_post.validate))!="undefined"){
if(f("validate")=="")
{
alert("请填写验证码");
return false;
}else{
validate=f("validate");
}
}
if((typeof eval(document.ajax_post.password))!="undefined"){
password=f("password");
}
data="username="+escape(f("username"))+"&password="+escape(password)+"&validate="+escape(validate)+"&log_dissm="+escape(log_dissm)+"&log_disurl="+escape(log_disurl)+"&log_diskey="+escape(log_diskey)+"&message="+escape(f("message"))+"&logid="+escape(f("logid"))+"&action="+escape(f("action"));
//alert(data);
postdata("wbc_blogcomm.asp","showresult",data);
return true;
}
document.write('<div id="loadingg" style="height:65px; width: 200px;position: absolute; z-index:1000;border:3px;solid;text-align:center;sans-serif;color:#000000;background-color:#ffffff;opacity:.7;-moz-opacity:.7;filter: alpha(opacity=75, finishopacity=50, style=1, startx=0, starty=1, finishx=200, finishy=100); display:none;"><br/><font color="#708090"><b>数据正在读取中,请等候...</b></font><br/><img src="images/loading.gif"/></div>')
function showloading()
{
var obj=document.getelementbyid("loadingg")
if (obj.style.display!="")
{
obj.style.left=((document.documentelement.clientwidth-parsefloat (obj.style.width))/2)+document.documentelement.scrollleft+"px";
obj.style.top=((document.documentelement.clientheight-parsefloat (obj.style.height))/2)+document.documentelement.scrolltop+"px";
obj.style.display="";
}else{obj.style.display="none";}
}
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;
}
showloading()
xmlhttp.onreadystatechange=requestdata;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
function requestdata()
{
fopen(obj1);
//echo(obj1,"正在加载数据,请稍等......");
//alert(xmlhttp.readystate)
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
if(obj1!=obj2){fclose(obj1);};
echo(obj2,xmlhttp.responsetext);
showloading()
}
}
}
}
function postdata(url,obj,data)
{ var rnd=math.random()
var xmlhttp=createxmlhttp();
if(!xmlhttp)
{
alert("你的浏览器不支持xmlhttp!!");
return;
}
showloading()
xmlhttp.open("post", url, true);
xmlhttp.onreadystatechange=requestdata;
xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded");
xmlhttp.send(data);
function requestdata()
{
fopen(obj);
echo(obj,"正在提交数据,请稍等......");
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
echo(obj,xmlhttp.responsetext);
reget(rnd);
settimeout("echo('showresult','')",2000);
echo('message','')
showloading()
}
}
}
}
function ltrim(str)
{
if (str.charat(0) == " ")
{
//如果字串左边第一个字符为空格
str = str.slice(1);//将空格从字串中去掉
//这一句也可改成 str = str.substring(1, str.length);
str = ltrim(str); //递归调用
}
return str;
}
//去掉字串右边的空格
function rtrim(str)
{
var ilength;
ilength = str.length;
if (str.charat(ilength - 1) == " ")
{
//如果字串右边第一个字符为空格
str = str.slice(0, ilength - 1);//将空格从字串中去掉
//这一句也可改成 str = str.substring(0, ilength - 1);
str = rtrim(str); //递归调用
}
return str;
}
//去掉字串两边的空格
function trim(str)
{
return ltrim(rtrim(str));
}
function f(obj)
{
return trim(eval("document.ajax_post."+obj+".value"));
//return trim($(obj).value);
}
function savereply()
{
if(f("username")=="")
{
alert("请填写用户名");
return false;
}
if(f("message")=="")
{
alert("内容不可為空");
return false;
}
var validate,password,log_diskey=0,log_disurl=0,log_dissm=0
validate=""
password=""
if(document.ajax_post.log_diskey.checked){
log_diskey=f("log_diskey")
}
if(document.ajax_post.log_disurl.checked){
log_disurl=f("log_disurl")
}
if(document.ajax_post.log_dissm.checked){
log_dissm=f("log_dissm")
}
if((typeof eval(document.ajax_post.validate))!="undefined"){
if(f("validate")=="")
{
alert("请填写验证码");
return false;
}else{
validate=f("validate");
}
}
if((typeof eval(document.ajax_post.password))!="undefined"){
password=f("password");
}
data="username="+escape(f("username"))+"&password="+escape(password)+"&validate="+escape(validate)+"&log_dissm="+escape(log_dissm)+"&log_disurl="+escape(log_disurl)+"&log_diskey="+escape(log_diskey)+"&message="+escape(f("message"))+"&logid="+escape(f("logid"))+"&action="+escape(f("action"));
//alert(data);
postdata("wbc_blogcomm.asp","showresult",data);
return true;
}
上一篇: Ajax实现无刷新三联动下拉框
下一篇: Linux安装redis和部署