I am working on a login form. The Ajax code is as follows: /* ---------------------------- / / XMLHTTPRequest Enable / / ---------------------------- */
function createObject()
{
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
var http = createObject();
/* -------------------------- */
/* LOGIN */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function login() {
// Optional: Show a waiting message in the layer with ID ajax_response
document.getElementById('login_response').innerHTML = "<img src='images/ispinner.gif'/>"
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var email = encodeURI(document.getElementById('emailLogin').value);
var psw = encodeURI(document.getElementById('pswLogin').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'login.php?email='+email+'&psw='+psw+'&nocache = '+nocache);
http.onreadystatechange = loginReply;
if(window.XMLHttpRequest)
{
http.send(null);
}
else
{
http.send()
}
}
function loginReply() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('login_response').innerHTML = response;
}
}
The code wors absoultely fine on google chrome and mozilla firefox. It just doesnt work on IE 5 and IE 6. I cannot figure out why? Please help
UPDATE Implemented few alert boxes in the code. found out that the execution in Internet explorer doesnot go beyond
document.getElementById('login_response').innerHTML = "<img src='images/ispinner.gif'/>"
Is there some other syntax to get the form values?