Using AJAX for WHOIS queries

Source: Internet
Author: User
Tags chr

Ajax said novel is not novel technology , if you have used Google Map service will realize his advantages, of course, can not be used, hehe!
The following is a small example of their own writing, for reference only, laughed!

is to call the WHOIS query for 7e
Detailed content can go online search ~
The specific code is as follows:

main.html content



< HTML >
< Head >
< title > invoking WHOIS queries with Ajax </ title >
< Meta http-equiv = "Content-type" content = "text/html charset=gb2312" >
< META NAME = "keywords" CONTENT = "Call whois query with Ajax" >
< META NAME = "description" CONTENT = "Call whois query with Ajax" >
< META NAME = "Robots" CONTENT = "All" >
< META name = "AUTHOR" content = "Anlige" >
</ Head >
< Body >
< form name = "se" >
< input type = "text" name = "Domain" >
< input type = "button" value = "Query" onclick = "Star (se.domain.value)" >
</ form >
< Div ID =whois >
</ Div >
</ Script ></ span ></ TD >
</ Body >
</ HTML >
< Script language = "JavaScript" src = "Fun.js" ></ Script >
<!-- The following VBScript is decoded and is not used here for a while. -->
< Script language = "VBScript" > ...
Function STR2ASC (STRSTR)
STR2ASC = hex(ASC(STRSTR))
End Function
Function Asc2str (ASCASC)
Asc2str = chr(ASCASC)
End Function
</ Script >


Fun.js Content



var Obao;
var obj
// Creating Components
function createobj () ... {
if(window. ActiveXObject)...{
Obao=new ActiveXObject ("microsoft.xmlhttp" );
}
Else if(window. XMLHttpRequest)...{
Obao=new XMLHttpRequest ();
}
}
// Send Request
function Star (domain) ... {
//The following defines two variables to hold the URL of the WHOIS query used to catch 72e
obj=document.getElementById ("whois"); //Navigate to Div
vara="http://www.72e.net/domain/whois/jswhois.aspx?DomainName=";
varb="&sourcehost=www.72e.net&sourcepath=/domain/&showdetail=1";
Createobj (); //Create XMLHttpRequest
varMy_url=a+Domain+b; //the URL to request
Obao.open ("POST", My_url,true); //Post method Request My_url, asynchronous execution (send complete can continue to execute the following code without waiting for the server to return results)
Obao.onreadystatechange=SetValue; //setting event handler functions
Obao.send (NULL); //Send Request
}
// event handler function
function SetValue () ... {
if(Obao.readystate==4)...{                    //4 represents that the data has been returned from the server
      if(Obao.status== A)...{                 //200 represents a normal page
        varstrresult=Obao.responsetext; //get the return content in a textual way
        //The following is a separate intercept, showing what we need.
        varC=Strresult.search (/<Pre>/);
varD=Strresult.search (/</Pre>/);
varStr=Strresult.substr (c+5, D-C-5);
Obj.innerhtml=Str.replace (/__crlf__/gi,''<br>''); //Display Information
      }Else...{
obj.innerhtml=" server returned an error! " " ;
}
}Else...{
obj.innerhtml=" data Request ... " ;
}
}

// It's not for a while.
function UrlDecode (str) ... {
varret="";
for(varI=0; I<Str.length;i++)...{
varCHR=Str.charat (i);
if(CHR== "+")...{
RET=" ";
}Else if(CHR=="%")...{
varASC=str.substring (i+1, I+3);
if(parseint ("0x"+ASC)>0x7f)...{
RET+asc2str (parseint ("0x"+ASC+ str.substring (i+4, I+6));
I+5;
}Else...{
RET+asc2str (parseint ("0x"+asc));
I+2;
}
}Else...{
RET+ chr;
}
}
returnret;
}
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.