AJAX Help
I've recently been working on some Web 2.0 applications (and partially modeling them after Vanilla) but I've hit a snag with AJAX: The forms can only be submitted once. Does anyone know how to enable multiple submissions? Here's my current code:
As you can imagine, this becomes a major issue when users need to revise information, such as on a login screen. Thanks in advance to anyone who helps.
<input type="button" value="Log In" onClick=" login();" />
As you can imagine, this becomes a major issue when users need to revise information, such as on a login screen. Thanks in advance to anyone who helps.
0
This discussion has been closed.
Comments
//AJAX stuff. var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari, ... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); // See note below about this line } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } http_request.onreadystatechange = function(){ //Handle response and keep the user up-to-date on what's going on. if(http_request.readyState == 4) { if(http_request.status == 200) { if(http_request.responseText == "success") { Effect.SlideUp('form'); document.getElementById('form').innerHTML="You have been logged in. <a href=\"home.php\">Proceed</a>"; Effect.Appear('form'); document.getElementById('status').innerHTML='Logged In'; } else { document.getElementById('status').style.display='none'; document.getElementById('error').style.color="#cc0000"; document.getElementById('error').innerHTML="Incorrect username/password."; Effect.Appear('error'); Effect.Shake('form'); } } else { document.getElementById('error').style.color="#cc0000"; document.getElementById('error').innerHTML="Error "+ http_request.status +" has occurred and you couldn't be logged in. Please try again later."; Effect.SlideDown('error'); document.getElementById('status').style.display='none'; } } else document.getElementById('status').innerHTML="Authenticating..."; }; function login() { var username = document.getElementById('user').value; var password = document.getElementById('pass').value; http_request.open('POST', 'index.php?sid='+ Math.random(), true); http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http_request.send("submitted=true&username="+username+"&password="+password); } //]]>