Ajax Implementation Comment Submission

Source: Internet
Author: User
Tags eval return rtrim string trim
Ajax document.write ('
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) {//Set MIME category
Xmlhttp.overridemimetype (' Text/xml ');
}
}
return XMLHTTP;
}
function GetData (URL,OBJ1,OBJ2)
{var xmlhttp=createxmlhttp ();
if (!xmlhttp)
{Alert ("Your browser does not support xmlhttp!! ");
Return
}
Showloading ()
Xmlhttp.onreadystatechange=requestdata;
Xmlhttp.open ("Get", url,true);
Xmlhttp.send (NULL);
function RequestData ()
{fopen (OBJ1);
Echo (obj1, "Loading data, please wait ...");
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 ("Your browser does not support 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, "submitting data, please wait ...");
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) = = "")
{
If the first character on the left of the string is a space
str = str.slice (1);//Remove the space from the string
This sentence can also be changed to str = str.substring (1, str.length);
str = LTrim (str); Recursive call
}
return str;
}
Remove the space on the right side of the string
function RTrim (str)
{
var ilength;
Ilength = Str.length;
if (Str.charat (iLength-1) = "")
{
If the first character to the right of the string is a space
str = str.slice (0, iLength-1);//Remove spaces from string
This sentence can also be changed to str = str.substring (0, iLength-1);
str = RTrim (str); Recursive call
}
return str;
}
Remove the spaces on either side of the string
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 ("Please fill in User name");
return false;
}
if (f ("message") = = "")
{Alert ("content is not nullable");
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 ("Please fill in the Verification Code");
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;
}


Related Article

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.