Jump to content

ms xmlhttp doing nonsense


r-it

Recommended Posts

i have this code:

<script>
function dologin(f)
{
var login = f.txLogin.value;
var pass = f.txPass.value;
var val = "top";

var obj = document.getElementById(val);
var url = "check.php?logn=" + login + "&pass=" + pass;
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function()
{
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
	{
		obj.innerHTML = xmlhttp.responseText;

	}

}

xmlhttp.send(null);
}
</script>

 

which basically handles my login form

 

the thing is that it works fine in firefox, but internet explorer 6 is giving me a headache as it is just reloading the page instead of showing a message, i have not made a function for creating the mttprequests, they are rather declared at the top of my js script and are used (globally) throughout the script:

//create a boolean variable to check for a valid IE instance
var xmlhttp = false;

//check if user's using IE
try
{
//check if jvascript version is rgeater than 5.
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");
}
catch (e)
{
//if nt, then use older active x object
try
{
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
	//else, user's not using IE
	xmlhttp = false;
}
}

//if user's using a non-ie browser, create a javascript instance of the obj
if(!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
xmlhttp = new XMLHttpRequest();
}

 

the reloading happens after i get the responseText back, it completely reloads the page, and when i put an alert after the responsetext, then i can see the message in the page behind the alertbox, but as soon as i click ok, it reloads the page again, plz help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.