Get comments from chinaz Ajax code

Source: Internet
Author: User

The characters obtained by Ajax are similar to the following content: CopyCode The Code is as follows: {A: "<Div class = 'pl _ list'> <div> <SPAN class = 'float _ right'> <a href = javascript: goodbad (22835,26769, 'Good', 1) Title = 'supported '> supported: [0] </a> <a href = javascript: goodbad (22835,26769, 'bad', 1) title = 'my object'> objection: [0] </a> </span> <SPAN class = 'zz '> Chinese webmaster site: Anonymous on commented: </span> </div> who thinks that Google Adsense websites cannot be promoted? Dummies </div> ", B: 1}

Then use the following Ajax for output.Copy codeThe Code is as follows:

Var key = '';
VaR STR = new array ();

Function createajaxobj (){
VaR httprequest = false
// Document. Domain = 'chinaz. com ';
If (window. XMLHttpRequest) {// If Mozilla, Safari etc
Httprequest = new XMLHttpRequest ()
If (httprequest. overridemimetype)
Httprequest. overridemimetype ('text/xml ');
}
Else if (window. activexobject) {// If IE
Try
{
Httprequest = new activexobject ("msxml2.xmlhttp ");
}
Catch (E)
{
Try
{
Httprequest = new activexobject ("Microsoft. XMLHTTP ");
}
Catch (e ){}
}
}
Return httprequest;
}

Function load_feedback (arcid, PG ){

/*
VaR url = "http://www.chinaz.com/plus/feedback_ajax.php? Action = show & arcid = "+ arcid +" & Pg = "+ PG;
VaR Ajax = new oajax ();
// Whether an error is displayed
// Ajax. Error = true;
// The requested page is encoded as 'gb2312' or empty.
// Ajax. encode = 'gb2312 ';
// Callback function
Ajax. Callback = function (content ){
// Process the returned content
Eval ('var OBJ = '+ content );
Document. getelementbyid ('bk BK '). innerhtml = obj.;
Document. getelementbyid ('fedcount'). innerhtml = obj. B;
};
Ajax. Send (URL );
*/

VaR XMLHTTP = createajaxobj ();
Try
{

VaR Params = "Action = show & arcid =" + arcid + "& Pg =" + PG;
XMLHTTP. Abort ();

XMLHTTP. Open ("get", "/plus/feedback_ajax.php? "+ Params, true );

XMLHTTP. setRequestHeader ("Content-Type", "text/html; charset = gb2312 ");

XMLHTTP. setRequestHeader ("If-modified-since", "0 ");

XMLHTTP. setRequestHeader ("Content-Length", Params. Length );

XMLHTTP. setRequestHeader ("connection", "close ");

XMLHTTP. onreadystatechange = f

XMLHTTP. Send (null );

} Catch (Ex ){}
Function f ()
{

If (XMLHTTP. readystate! = 4 | XMLHTTP. status! = 200)
Return;
VaR B = XMLHTTP. responsetext;
VaR OBJ = eval ("(" + B + ")");
Document. getelementbyid ('bk BK '). innerhtml = obj.;
Document. getelementbyid ('fedcount'). innerhtml = obj. B;
Document. getelementbyid ('feedcounttop '). innerhtml = obj. B;
}
}

Function load_allfeedback (arcid, PG ){

VaR XMLHTTP = createajaxobj ();
Try
{

VaR Params = "Action = showall & arcid =" + arcid + "& Pg =" + PG;
XMLHTTP. Abort ();

XMLHTTP. Open ("get", "/plus/feedback_ajax.php? "+ Params, true );

XMLHTTP. setRequestHeader ("Content-Type", "text/html; charset = gb2312 ");

XMLHTTP. setRequestHeader ("If-modified-since", "0 ");

XMLHTTP. setRequestHeader ("Content-Length", Params. Length );

XMLHTTP. setRequestHeader ("connection", "close ");

XMLHTTP. onreadystatechange = f

XMLHTTP. Send (null );

} Catch (Ex ){}
Function f ()
{

If (XMLHTTP. readystate! = 4 | XMLHTTP. status! = 200)
Return;
VaR content = XMLHTTP. responsetext;
VaR OBJ = eval ("(" + content + ")");
// Eval ('var OBJ = '+ content );
Document. getelementbyid ('bk BK '). innerhtml = obj.;
// Document. getelementbyid ('fedcount'). innerhtml = obj. B;
}
}

Function feed_back (){

VaR MSG = trim (document. getelementbyid ('msg '). value );
VaR arcid = Document. getelementbyid ('arcid'). value;
VaR username = trim (document. getelementbyid ('username'). value );
VaR Pwd = trim (document. getelementbyid ('pwd'). value );
VaR checkbox = Document. getelementbyid ('notuser ');
If (checkbox. Checked)
VaR notuser = 1;
Else
VaR notuser = 0;

VaR XMLHTTP = createajaxobj ();
Try
{

Params = "Action = Send & arcid =" + arcid + "& MSG =" + MSG + "& username =" + Username
+ "& Pwd =" + PWD + "& notuser =" + notuser;

XMLHTTP. Abort ();

XMLHTTP. Open ("get", "/plus/feedback_ajax.php? "+ Params, true );

XMLHTTP. setRequestHeader ("Content-Type", "text/html; charset = gb2312 ");

XMLHTTP. setRequestHeader ("If-modified-since", "0 ");

XMLHTTP. setRequestHeader ("Content-Length", Params. Length );

XMLHTTP. setRequestHeader ("connection", "close ");

XMLHTTP. onreadystatechange = f

XMLHTTP. Send (null );

} Catch (Ex ){}
Function f ()
{
If (XMLHTTP. readystate! = 4 | XMLHTTP. status! = 200)
Return;
VaR arr = XMLHTTP. responsetext. Split ("@:");

If (! Arr [1]) {
Alert (XMLHTTP. responsetext );
}
Else {
If (ARR [0]! = 'True ')
Alert (ARR [0]);
Alert (ARR [2]);
Ck_yzimg ();
Load_feedback (ARR [1], 1 );
}
}

}

Function goodbad (FID, arcid, actname, PG ){

VaR XMLHTTP = createajaxobj ();

Try
{
Params = "Action =" + actname + "& FID =" + FID + "& arcid =" + arcid + "& Pg =" + PG;

XMLHTTP. Abort ();

XMLHTTP. Open ("get", "/plus/feedback_ajax.php? "+ Params, true );

XMLHTTP. setRequestHeader ("Content-Type", "text/html; charset = gb2312 ");

XMLHTTP. setRequestHeader ("If-modified-since", "0 ");

XMLHTTP. setRequestHeader ("Content-Length", Params. Length );

XMLHTTP. setRequestHeader ("connection", "close ");

XMLHTTP. onreadystatechange = f

XMLHTTP. Send (null );

} Catch (Ex ){}
Function f ()
{
If (XMLHTTP. readystate! = 4 | XMLHTTP. status! = 200)
Return;
VaR arr = XMLHTTP. responsetext. Split ("@:");

If (! Arr [1])
Alert (XMLHTTP. responsetext );
Else {
Alert (ARR [0]);
Load_feedback (ARR [1], arr [2]);
}
}

}

Function goodbad2 (FID, arcid, actname, PG ){

VaR XMLHTTP = createajaxobj ();

Try
{
Params = "Action =" + actname + "& FID =" + FID + "& arcid =" + arcid + "& Pg =" + PG;

XMLHTTP. Abort ();

XMLHTTP. Open ("get", "/plus/feedback_ajax.php? "+ Params, true );

XMLHTTP. setRequestHeader ("Content-Type", "text/html; charset = gb2312 ");

XMLHTTP. setRequestHeader ("If-modified-since", "0 ");

XMLHTTP. setRequestHeader ("Content-Length", Params. Length );

XMLHTTP. setRequestHeader ("connection", "close ");

XMLHTTP. onreadystatechange = f

XMLHTTP. Send (null );

} Catch (Ex ){}
Function f ()
{
If (XMLHTTP. readystate! = 4 | XMLHTTP. status! = 200)
Return;
VaR arr = XMLHTTP. responsetext. Split ("@:");

If (! Arr [1])
Alert (XMLHTTP. responsetext );
Else {
Alert (ARR [0]);
Load_allfeedback (ARR [1], arr [2]);
}
}

}

Function PG (VL ){
VaR arcid = Document. getelementbyid ('arcid'). value;
Load_feedback (arcid, VL );
}
Function pG2 (arcid, VL ){
// Var arcid = Document. getelementbyid ('arcid'). value;
Load_allfeedback (arcid, VL );
}
Function ck_yzimg (){
// Document. All. cknum. value = '';
Document. All. msg. value = '';
Document. All. username. value = '';
Document. All. pwd. value = '';
Document. getelementsbyname ('SB ') [0]. Disabled = false;
// Document. All. img1.onclick ();
}

Function trim (s ){
Return S. Replace (/^ \ s */, ""). Replace (/\ s * $ /,"");

}

///
/*
string. prototype. contains = function (STR) {
return (this. indexof (STR)>-1);
};
var browser ={< br> S: navigator. useragent. tolowercase ()
};
(function (B) {
B. isie = B. s. contains ('msi');
B. isie5 = B. s. contains ('msie 5');
B. isie6 = B. s. contains ('msie 6');
B. isie7 = B. s. contains ('msie 7');
B. isie56 =! B. isie7 & (B. isie6 | B. isie5);
B. isgecko = B. s. contains ('gecko ');
B. issafari = B. s. contains ('safari ');
B. isopera = B. s. contains ('Opera ');
B. ismac = B. s. contains ('macintosh ');

B. isielike = (B. isie | B. isopera);
B. isgeckolike = (B. isgecko | B. issafari);
}) (browser);
function oajax () {
This. req = NULL;
This. url = '';
This. content = '';
This. type = 'text';
This. encode = '';
This. asyn = true;
This. action = 'get';
This. error = false;
}< br> oajax. prototype. init = function () {
If (window. XMLHttpRequest) {
This. req = new XMLHttpRequest ();
}< br> else if (window. activexobject) {
// isie = true;
try {
This. req = new activexobject ("msxml2.xmlhttp");
}< br> catch (e) {
try {
This. req = new activexobject ("Microsoft. XMLHTTP ");
}< br> catch (e) {
This. req = false;
}< BR >}< br> var self = This;
If (this. REQ) {
This. req. onreadystatechange = function () {self. listener () };< BR >}< BR >};

Oajax. Prototype. Listener = function (){
If (this. Req. readystate = 4 ){
If (this. Req. Status = 200 ){
// Right
Try {
This. Callback (browser. isie & this. encode = 'gb2312 '? Oajax. gb2utf8 (this. Req. responsebody): (this. type = 'text '? This. Req. responsetext: This. Req. responsexml ));
}
Catch (e ){
This. Halt ('[callback]' + E. Name + ':' + E. Message );
}
}
Else {
// Error
This. Halt ('[callback Error]' + this. Req. status );
}
}
};

Oajax. Prototype. Send = function (URL ){
This. INIT ();

url = This. url = URL | this. url | '';
This. content = !! This. content? This. Content: '';
This. encode = This. encode? This. encode. tolowercase (): '';
This. Asyn = This. Asyn = undefined? True :!! This. Asyn;
This. Action = (this. Action = undefined | this. Action = 'get ')? 'Get': 'post';
This. Error = This. Error = undefined? False :!! This. error;

If (! URL & this. Error ){
Alert ('ajax request URL cannot be blank. ');
Return;
}
Try {
This. Req. Open (this. Action, URL, this. Asyn );
}
Catch (e ){
This. Halt ('[open]' + E. Name + ':' + E. Message );
Return;
}
Try {
This. Req. setRequestHeader ('connection', 'close ');
This. Req. setRequestHeader ('Accept-encoding ', 'gzip, deflate ');
This. Req. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded' + (this. encode? '; Charset =' + this. encode :''));
If (this. Req. overridemimetype & this. encode ){
This. Req. overridemimetype ('text/xml' + (this. encode? '; Charset =' + this. encode :''));
}
This. Req. Send (this. content );
}
Catch (e ){
This. Halt ('[open]' + E. Name + ':' + E. Message + '\ n ** check whether CORS is enabled. ');
}
};

Oajax. Prototype. Callback = function (content ){
// Alert (content );
};

// Abort
Oajax. Prototype. Abort = function (){
This. Req. Abort ();
};

Oajax. Prototype. Halt = function (description ){
This. Error & alert (description );
};

// Gb2312 to utf8
Oajax. gb2utf8 = function (data ){
VaR glbencode = [];
Gb2utf8_data = data;
ExecScript ("gb2utf8_data = midb (gb2utf8_data, 1)", "VBScript ");
VaR T = escape (gb2utf8_data ). replace (/% u/g ,""). replace (/(. {2 })(. {2})/g, "%$ 2% $1 "). replace (/% ([A-Z].) % (. {2})/g, "@ $1 $2 ");
T = T. Split ("@");
VaR I = 0, j = T. length, K;
While (++ I <j ){
K = T [I]. substring (0, 4 );
If (! Glbencode [k]) {
Gb2utf8_char = eval ("0x" + k );
ExecScript ("gb2utf8_char = CHR (gb2utf8_char)", "VBScript ");
Glbencode [k] = escape (gb2utf8_char). substring (1, 6 );
}
T [I] = glbencode [k] + T [I]. substring (4 );
}
Gb2utf8_data = gb2utf8_char = NULL;
Return Unescape (T. Join ("% "));
}
*/

core code copy Code the code is as follows: var B = XMLHTTP. responsetext;
var OBJ = eval ("(" + B + ")");
document. getelementbyid ('bk BK '). innerhtml = obj. a;
document. getelementbyid ('fedcount '). innerhtml = obj. b;
document. getelementbyid ('feedcounttop '). innerhtml = obj. b;

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.