Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Javascript

Notices


 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-22-2015, 03:20 AM   #1
rakesvyas44
Registered User
 
Join Date: Dec 2014
Posts: 12
Ajax without jQuery

I've compiled the following code which works at processing my login form using Ajax without jQuery. Just not sure if it's the most efficient way to do it and hoping someone can advise if it can be improved any further.

var xmlhttp;

function loadXMLDoc(url,cfunc) {

if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject(""Microsoft.XMLHTTP"");
}

xmlhttp.onreadystatechange=cfunc;
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader(""Content-type"", ""application/x-www-form-urlencoded"");
xmlhttp.send(""username="" + document.getElementById(""username"").value + ""&passwd="" + document.getElementById(""passwd"").value + ""&_SESSION="" + document.getElementById(""_SESSION"").value);

}

function Login() {

loadXMLDoc(""/Login.php"",function() {
document.getElementById(""ErrorBox"").style.displa y = ""none"";
document.getElementById(""SignInButton"").value="" please wait.."";
document.getElementById(""SignInButton"").setAttri bute(""disabled"",""disabled"");
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var loginResponse = xmlhttp.responseText;

if (loginResponse == 2) {
window.location=""/portal/"";
} else if (loginResponse == 3) {
document.getElementById(""staffErrorBox"").style.d isplay = ""block"";
document.getElementById(""staffErrorBox"").innerHT ML=""Error"";
document.getElementById(""SignInButton"").value="" Sign In"";
document.getElementById(""SignInButton"").removeAt tribute(""disabled"");
} else {
document.getElementById(""SignInButton"").value="" Sign In"";
document.getElementById(""SignInButton"").removeAt tribute(""disabled"");
}


}
});
}"
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
rakesvyas44 is offline   Reply With Quote

 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do hide a column using JQuery? Jack Hard Java 3 10-09-2014 11:15 PM
Free Awesome jQuery Count Down/Up Timer Scripts JavaScriptBank Javascript 0 04-09-2013 06:09 AM
jQuery Plugins Webmastergrace Web Promotion 0 09-27-2012 09:23 PM
Problem with jquery and WP ArtphotoasiA Javascript 4 04-02-2012 04:38 AM
Looking For Jquery Expert! Need To Install Videolightbox on My Site $$ shakemelikeapig Wanted 0 02-16-2012 02:25 PM


All times are GMT -7. The time now is 04:51 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.