var xmlhttp;ajax function, user registration _ Detection
Defining AJAX functions
function Ajax () {
if (window. XMLHttpRequest)
{
XmlHttp = new XMLHttpRequest ();//mozilla browser
}
else if (window. ActiveXObject)
{
Try
{
XmlHttp = new Activex0bject ("Msxml2.xmlhttp");//ie old version
}
catch (E)
{}
Try
{
XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
}
catch (E)
{}
if (!xmlhttp)
{
Window.alert ("Cannot create XMLHttpRequest object instance");
return false;
}
}
}
Get mode
function Ajaxget (url,allid) {
Ajax ()//calling Ajax functions
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readystate = 4) {
if (xmlhttp.status = =) {
document.getElementById (allid). InnerHTML = Xmlhttp.responsetext;
} else {
document.getElementById (allid). InnerHTML = "request failed!";
}
}
}
xmlhttp.open (' Get ', url, true);
xmlhttp.send (null);
}
Post mode with data
function Ajaxpost (url,allid,form_obj) {
Gets all the values in the specified table Single-name
var theform = function () {
var query_string= ';
var and= ';
alert (form_obj.length);
for (i=0;i<form_obj.length; i++)
{
E=form_obj;
if (e.name!= ')
{
if (e.type== ' Select-one ')
{
Element_value=e.options[e.selectedindex].value;
}
else if (e.type== ' checkbox ' | | e.type== ' Radio ')
{
if (E.checked==false)
{
Break
}
Element_value=e.value;
}
Else
{
Element_value=e.value;
}
query_string+=and+e.name+ ' = ' +element_value.replace (/\&/g, "%26");
And= "&"
}
}
return query_string;
}//Get End
var thispost = theform ();//Assign the value of the form to the variable
Ajax ()//Call Ajax function
Xmlhttp.onreadystatechange = function () {
if (xmlhttp.readystate = = 4) {
if (Xmlhttp.status = = 200) {
document.getElementById (allid). InnerHTML = Xmlhttp.responsetext;
} else {
document.getElementById (allid). InnerHTML = "request failed!";
}
}
}
Xmlhttp.open (' POST ', url, true);
Xmlhttp.setrequestheader (' Content-type ', ' application/x-www-form-urlencoded; Charset=utf-8 ');
Xmlhttp.send (thispost)//Send thispost form data
}