Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 31st, 2007, 6:35 AM   #1
bewareofcabbage
Newbie
 
Join Date: Sep 2006
Posts: 1
Rep Power: 0 bewareofcabbage is on a distinguished road
Re-using XMLHttpRequest object (IE)

Hi guys, I've been tearing my hair out over this. Firefox accepts the following code perfectly, and executes the onreadystatechange function every time. However IE7 (I'm going to try IE6 at work tomorrow) will only execute the function once, any further AJAX requests stick on my "loading..." message, unless you refresh the page and start all over again.

I found articles about problems re-using the XMLHttpRequest object in IE, and they said to shift the onreadystatechange (in the "ajaxGet" function) below the open line (see http://keelypavan.blogspot.com/2006/...ect-in-ie.html ). But this isn't working for me, here's my javascript - any ideas greatly appreciated!

var xmlHttp;

function createXMLHttpRequest()
{
if (window.XMLHttpRequest) 
	{
	xmlHttp = new XMLHttpRequest();
	return xmlHttp;
	}
else if (window.ActiveXObject)
	{
	xmlHttp = ActiveXObject("Microsoft.XMLHTTP");
	return xmlHttp;
	} 
}

function handleStateChange(divID)
{
if(xmlHttp.readyState == 4)
	{
	if(xmlHttp.status == 200)
		{
		document.getElementById(divID).innerHTML = xmlHttp.responseText;
		}
	}
}

function ajaxGet(divID, URL, loadmsg)
{
	createXMLHttpRequest();
	xmlHttp.open("GET", URL, true);
	xmlHttp.onreadystatechange = function() { handleStateChange(divID); } ;
	xmlHttp.send(null);
	if(loadmsg != "") { document.getElementById(divID).innerHTML = '<div style="color:#A9A9A9; padding:5px;"><img src="_img/parts/progress_ball.gif" style="vertical-align:text-bottom;"> ' + loadmsg + "</div>"; }
	return false;
}
bewareofcabbage is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
review my code mrynit Java 8 Apr 29th, 2007 10:52 PM
Dealing with SNMP MIB object ids. hoffmandirt Software Design and Algorithms 0 Apr 13th, 2007 1:48 PM
Level Editor frankish Show Off Your Open Source Projects 47 Jul 10th, 2006 6:57 PM
Object Pascal Q: object instance as parameter KodeKid Delphi 1 May 16th, 2006 12:06 PM
XMLHTTPRequest Help in IE sunny_boy JavaScript and Client-Side Browser Scripting 4 Jun 25th, 2005 11:33 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC