Jump to content

again ajax ie problem


freenity

Recommended Posts

Hi

Actually it's a very strange problem it works fine in firefox but not in IE. I tried IE 6 and 7. The problem is that I have a link to an ajax requested page. When I click on this link for the first time it works but if I click again, it doesnt. It doesnt even enters the ob.onreadystatechange = function()

 

Here is the code:

 

function getdata(url, obname, loading)
{
var ob;

if (window.XMLHttpRequest)
{
	ob = new XMLHttpRequest();	
}
else
{
	if (window.ActiveXObject)
		ob = new ActiveXObject("Microsoft.XMLHTTP");
}

if (loading)
	document.getElementById(obname).innerHTML = "<center>Loading...</center>";

ob.open("GET", url, true);
ob.send(null);

ob.onreadystatechange = function()
{    /*line 65 error here */
	if ((ob.status == 200) && (ob.readyState == 4))
	{
		document.getElementById(obname).innerHTML = ob.responseText;
	}
}	
}

 

IE show an error on line 65 char 3. system error: -22147467259

 

Thanks for any help

Link to comment
https://forums.phpfreaks.com/topic/91077-again-ajax-ie-problem/
Share on other sites

SOLVED :)

 

Just had to change

 

ob.open("GET", url, true);
ob.send(null);

ob.onreadystatechange = function()
{    /*line 65 error here */
	if ((ob.status == 200) && (ob.readyState == 4))
	{
		document.getElementById(obname).innerHTML = ob.responseText;
	}
}	

 

to

 

ob.onreadystatechange = function()
{
	if ((ob.status == 200) && (ob.readyState == 4))
	{
		document.getElementById(obname).innerHTML = ob.responseText;
	}
}

ob.open("get", url, true);
ob.send(null);

 

weird :S

Link to comment
https://forums.phpfreaks.com/topic/91077-again-ajax-ie-problem/#findComment-466847
Share on other sites

ob.open("get", url, true);
ob.onreadystatechange = function() { your code  here }
ob.send(null);

the most cross browser way to code that is to run the .open() first, then the .onreadystatechange=, and then the .send().  Coding in a different order will cause problems on some browsers

Link to comment
https://forums.phpfreaks.com/topic/91077-again-ajax-ie-problem/#findComment-468936
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.