Some nice js functions ajax

Source: Internet
Author: User

// Create a component
Function createobj (){
If (window. ActiveXObject ){
Return (new ActiveXObject ("Microsoft. XMLHTTP "));
}
Else if (window. XMLHttpRequest ){
Return (new XMLHttpRequest ());
}
}

Var cs;
// Send the request
Function sxs (Fileid ){
If (window. ActiveXObject ){
Cs = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest ){
Cs = new XMLHttpRequest ();
}
Var my_url = "inc/setsession. asp? Id = "+ Fileid +" & rnd = "+ Math. random ();
Cs. open ("get", my_url, true );
Cs. send (null );
}

// Call and return results
Function Star (){
Var oBao = createobj ();
Var frm = document. logo_frm;
Var my_url = "logo. asp? Name = "+ frm. username. value +" & pw = "+ frm. pwd. value +" & rnd = "+ Math. random ();
OBao. open ("POST", my_url, false );
OBao. send ('');
Var strResult = unescape (oBao. responseText );
If (strResult = "yes "){
Window. location. reload ();
}
Else {
Alert ("Logon Failed! Please log on again ...");
Frm. username. value = "";
Frm. pwd. value = "";
Hide ();
}
}
Var h_id;
Var h_ I = 0;
// Call and return results, menu
Function getinfo (index ){
Var oBao = createobj ();
Var cont = document. getElementById ("menu_detial ");
Cont. style. top = '142px ';
Cont. style. left = event. x-60;
If (! Bro_n ){
Cont. style. top = '142px ';
Cont. style. left = event. x-60;
}
Cont. style. width = '150px ';
Cont. style. display = "block ";
Cont. innerHTML = "Please wait, loading ...";
Cont. style. height = "10px ";
Cont. style. overflowY = "hidden ";
Var my_url = "getinfo. asp? Type = "+ index +" & rnd = "+ Math. random ();
OBao. open ('post', my_url, true );
OBao. onreadystatechange = function (){
Var cont = document. getElementById ("menu_detial ");
If (oBao. readyState = 4 ){
If (oBao. status = 200 ){
Cont. innerHTML = oBao. responseText;
H_ I = 0;
H_id = window. setInterval ("h_change ()", 30 );
} Else {
Cont. innerHTML = 'error, error code:' + oBao. status;
}
}
}
OBao. send ('');
}

Function h_change (){
Var cont = document. getElementById ("menu_detial ");
H_ I + = 1;
H = parseInt (cont. style. height );
If (G> 133 ){
Window. clearInterval (h_id );
H_ I = 0;
} Else {
Cont. style. height = 16 + 8 * h_i-h_ I * h_ I * 0.1 + "px ";
}
}


// Call and return results
Function personalInfo (index ){
Var oBao = createobj ();
Var cont = document. getElementById ("person_detial ");
Var cont_a = document. getElementById ("person_content ");
Cont. style. display = 'block ';
Cont. style. width = "600px ";
Cont. style. top = event. y;
Cont_a.innerHTML = "Please wait, loading ...";
Var my_url = "getinfo. asp? Type = "+ index +" & rnd = "+ Math. random ();
OBao. open ('post', my_url, true );
OBao. onreadystatechange = function (){
Var cont_a = document. getElementById ("person_content ");
If (oBao. readyState = 4 ){
If (oBao. status = 200 ){
Cont_a.innerHTML = oBao. responseText;
} Else {
Cont_a.innerHTML = 'error. Error code:' + oBao. status;
}
}
}
OBao. send ('');
}

// Call and return results
Function getNotice (id ){
Var oBao = createobj ();
Var my_url = "notice. asp? Id = "+ id +" & rnd = "+ Math. random ();
OBao. open ('get', my_url, true );
OBao. onreadystatechange = function (){
Var cont_a = document. getElementById ("notice ");
If (oBao. readyState = 4 ){
If (oBao. status = 200 ){
If (cont_a ){
Cont_a.innerHTML = oBao. responseText;
}
} Else {
Cont_a.innerHTML = 'error. Error code:' + oBao. status;
}
}
}
OBao. send ('');
}

Var notice_id = window. setInterval ("getNotice (0)", 6000 );

// Call and return results
Function getnoticeById (id ){
Var cont_a = document. getElementById ("stip_detial ");
Cont_a.style.display = "block ";
Cont_a.style.top = event. y;
Cont_a.style.left = event. x-145;
Cont_a.innerHTML = "loading ...";
Var oBao = createobj ();
Var my_url = "getstip. asp? Id = "+ id +" & rnd = "+ Math. random ();
OBao. open ('get', my_url, true );
OBao. onreadystatechange = function (){
If (oBao. readyState = 4 ){
If (oBao. status = 200 ){
If (cont_a ){
Cont_a.innerHTML = oBao. responseText;
}
} Else {
Cont_a.innerHTML = 'error. Error code:' + oBao. status;
}
}
}
OBao. send ('');
}

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.