The ASP realizes the dig function The JS code _ Application Skill

Source: Internet
Author: User
Ajax controls
function Diggajax () {
var xhrobj=null;
if (window. XMLHttpRequest) {
Xhrobj=new XMLHttpRequest ();
}
else if (window. ActiveXObject) {
try{
Xhrobj=new ActiveXObject ("Microsoft.XMLHTTP");
}
catch (E1)
{
try{
Xhrobj=new ActiveXObject ("MSXML2"). XMLHTTP ");
}
catch (E2) {
try{
Xhrobj=new ActiveXObject ("MSXML3"). XMLHTTP ");
}
catch (E3) {
Alert ("Create Ajax failed:" +e3)
}
}
}
}
Else
{
Alert ("Browser not recognized");
}
return xhrobj;
}
var loader=new diggajax;
function Ajaxloadpage (url,request,method,fun)
{
Method=method.touppercase ();
if (method== ' get ')
{
Urls=url.split ("?");
if (urls[1]== ' | | typeof urls[1]== ' undefined ')
{
url=urls[0]+ "?" +request;
}
Else
{
url=urls[0]+ "?" +urls[1]+ "&" +request;
}

Request=null;
}
Loader.open (method,url,true);
if (method== "POST")
{
Loader.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
}
Loader.onreadystatechange=function () {
Eval (fun+ ' () ');
}
Loader.send (Request);
}
function callbacks ()
{
if (loader.readystate==4)
{
var S=loader.responsetext;
Switch (s)
{
Case "Err":
Alert (' Digg error! ');
Break
Case "Over":
Alert (' You've already recommended it! ');
Break
Case "Nologin":
Alert (' You are not logged in, can not recommend! ');
Break
Default
var sarr=s.split (' | ');
Eval ("Document.all.s" +sarr[0]). Innerhtml=sarr[1];
Eval ("DOCUMENT.ALL.D" +sarr[0]). innerhtml= "Thanks";

}

}
}


Digg
Function Digg (Channelid,infoid,installdir)
{
Ajaxloadpage (installdir+ ' plus/digg.asp ', ' action=hits&channelid= ' +channelid+ ' &infoid= ', ' +infoid ', ' post ', ' Callbacks ');

}
function Show_digg (channelid,infoid,installdir)
{
var xhr=new diggajax ();
Xhr.open ("Get", installdir+ "plus/digg.asp?channelid=" +channelid+ "&infoid=" +infoid+ "&action=show", true);
Xhr.onreadystatechange=function () {
if (xhr.readystate==1)
{
Eval ("Document.all.s" +infoid). innerhtml= "}
else if (xhr.readystate==2 | | xhr.readystate==3)
{
Eval ("Document.all.s" +infoid). innerhtml= "}
else if (xhr.readystate==4)
{
if (xhr.status==200)
{
var r=xhr.responsetext
var rarr=r.split (' | ');
Eval ("Document.all.s" +infoid). Innerhtml=rarr[1];
}
}
}
Xhr.send (NULL);
}

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.