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