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
https://forums.phpfreaks.com/topic/53597-ms-xmlhttp-doing-nonsense/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.