Ajax Publishing Read comments

Source: Internet
Author: User
Tags object comments copy eval return rtrim string trim
Ajax

[Copy this Code] CODE:
-----------------------------Jack's note ajaxjs.js-----------------------------
Here is a window to display a wait
document.write ('

Showloading controls the display and hiding of waiting windows
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";}
}
$ () Gets the object of the specified ID
function $ (ID)
{
return document.getElementById (ID);
}
Echo () Displays the specified HTML to the specified object obj
function Echo (obj,html)
{
$ (obj). innerhtml=html;
}
fopen () to make the specified obj appear
function fopen (obj)
{
$ (obj). style.display= "";
}
Fclose () to hide the specified obj
function fclose (obj)
{
$ (obj). style.display= "None";
}
Createxmlhttp () Gets the XMLHttpRequest object and returns
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;
}
GetData () Gets the data of the specified URL displayed inside the Obj2, OBJ1 is the message of the procedure, which can be deleted
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 ()
}
}
}
}
PostData () sends the specified data to the URL address and uses obj to display the returned data
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 ()
}
}
}
}
LTrim () Remove the space to the left of the string
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;
}
RTrim () Remove the space to the right 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;
}
Trim () Remove the spaces on either side of the string
function Trim (str)
{
Return LTrim (RTrim (str));
}

F () has no universal meaning, only for specific objects
function f (obj)
{
Return Trim (eval ("Document.ajax_post.") +obj+ ". Value"));
Return Trim ($ (obj). value);
}
Savereply () is the check submit function for the form
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;
}

Call:
[Copy this Code] CODE:






Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.