« Return to the blog entry
Here is a modified way of logging on using AJAX...
Using the same form from Jake..
add this code to your jsHeader..
var oXmlHttp;
function getHTTPObject()
{
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
} else if (typeof ActiveXObject != "undefined") {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
throw new Error("XMLHttpRequest not supported");
}
function stateChanged()
if (oXmlHttp.readyState==4 || oXmlHttp.readyState=="complete")
document.write(oXmlHttp.responseText);
function login()
var content = '';
oXmlHttp = getHTTPObject();
oXmlHttp.onreadystatechange = stateChanged;
oXmlHttp.open( "POST", '/names.nsf?login', true );
oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
content += "&redirectto=" + document.getElementById('redirectto').value;
content += "&username=" + document.getElementById('form_email').value;
content += "&password=" + document.getElementById('form_password').value;
oXmlHttp.send(content);
and this to your form...
<input type ="button" value ="login" onclick= "login()">
everything else remains the same.
andy : notes411
Here is a modified way of logging on using AJAX...
Using the same form from Jake..
add this code to your jsHeader..
var oXmlHttp;
function getHTTPObject()
{
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
} else if (typeof ActiveXObject != "undefined") {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
throw new Error("XMLHttpRequest not supported");
}
}
function stateChanged()
{
if (oXmlHttp.readyState==4 || oXmlHttp.readyState=="complete")
{
document.write(oXmlHttp.responseText);
}
}
function login()
{
var content = '';
oXmlHttp = getHTTPObject();
oXmlHttp.onreadystatechange = stateChanged;
oXmlHttp.open( "POST", '/names.nsf?login', true );
oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
content += "&redirectto=" + document.getElementById('redirectto').value;
content += "&username=" + document.getElementById('form_email').value;
content += "&password=" + document.getElementById('form_password').value;
oXmlHttp.send(content);
}
and this to your form...
<input type ="button" value ="login" onclick= "login()">
everything else remains the same.
andy : notes411