Jump to content
  • Advertisement
Sign in to follow this  
Uthman

[web] this is retarded

This topic is 3612 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

<script type="text/javascript" language="javascript">
function AJAXObj( callback_function )
{
	var http_request = false;
	if( window.XMLHttpRequest )
	{
		http_request = new XMLHttpRequest();	// Mozilla, Safari,...
		if( http_request.overrideMimeType ) http_request.overrideMimeType('text/xml');
	
	} else if( window.ActiveXObject )
	{	// IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	
	if( !http_request )
	{
		alert('Browser doesn\'t support Ajax');
		return false;
	}

	http_request.onreadystatechange = function()
	{
		if( http_request.readyState == 4 )
		{
			if( http_request.status == 200 )
			{
				eval(callback_function + '(http_request.responseText)');	// eval(callback_function + '(http_request.responseXML)');
			} else
				alert('There was a problem with the request.(Code: ' + http_request.status + ')');
		}
	}

	return http_request;
}
   
function loadHTML(html_data)
{
	var ele = document.getElementById('ajaxcontent').innerHTML = html_data;

}

////////////////////////////////////////
////////////////////////////////////////

var getit = AJAXObj( 'loadHTML' );

function LoadNode( )
{	// If we wanna get fancy, we can display a loading image here (with a return-1 history on failure)
	if( !getit ) 
	{
		alert( "AJAX Object not defined!" );
	}
	
    if( getit.readyState == 4 || getit.readyState == 0)
    {
	    getit.open("GET", 'delme.htm', true);
		getit.send(null);
	}
}


</script>
<span style="cursor: pointer; text-decoration: underline" onclick="LoadNode()">open self</span>
<div id='ajaxcontent' type='text' size='20' name='ajaxcontent'>..End of Page
save this page to a file called 'delme.htm' and test it in IE vs firefox. why is the behavior in IE so strange (works one time only?) whereas in FFox, the behavior is repeatable?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Sander
You can't easily reuse the AJAX object in IE. See:
http://en.wikipedia.org/wiki/XMLHttpRequest#Reusing_XMLHttpRequest_Object_in_IE
http://keelypavan.blogspot.com/2006/03/reusing-xmlhttprequest-object-in-ie.html


I knew someone would have the answer. I found that once, and modified my code, but I took out the comments so if someone stole it, they'd be clueless. I probably should have left that comment in there.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!