AJAX ASP Query the database and get the return value

Source: Internet
Author: User

function Checkdomain () {
var domain = document.getElementById ("domain"). Value;
if (domain = = ") {
Alert ("Please fill in the domain name!") ");
document.getElementById ("domain"). focus ();
return false;
}
var info=domain.match (/^[a-z0-9]+$/);
if (!info) {
Alert ("Domain name must be composed of letters and numbers!") ");
document.getElementById ("domain"). focus ();
return false;
}else{
var xml=window.activexobject? New ActiveXObject ("Microsoft.XMLHTTP"): New XMLHttpRequest ();
Xml.open (' Get ', '/index.asp?r=company/checkdomain&domain= ' +domain,true);
Xml.send (");
Xml.onreadystatechange = function ()
{
if (xml.readystate = = 4 && xml.status = 200)
{
var result = Xml.responsetext;
document.getElementById ("Result"). innerHTML = result;
}
}
}
}

ASP code

<%
'-----------------------------------------------------------------
Dim username
Username=trim (Request.Form ("username")) ' receives AJAX-sent parameters
If Username= "" Then Response.End ()
'------------------------------------------------------------------
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * FROM test where username = '" &username& ""
Rs.Open sql,conn,1,1
'------------------------------------------------------------------
'--------if not found, return 0
'--------if found, return all matching items
If not (rs.eof and RS.BOF) then
Response.Write ("" &rs ("Time") & "")
Rs.close
Set rs=nothing
%>

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.