Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Include javascript by XMLHttpRequest (See related posts)


Original from http://www.exit12.org/archives/12

function include(jsFileLocation)
{
	if(window.XMLHttpRequest)
	{
		var req = new XMLHttpRequest();
	}
	else
	{
		var req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.open("GET", jsFileLocation,false);
	req.onreadystatechange = function()
	{
		if (req.readyState == 4)
		{
			window.eval(req.responseText);
		}
	}
	req.send(null);
}

Comments on this post

ki4ngel posts on Aug 02, 2007 at 02:24
This script does not involve an enormous risk with “eval()” ?

You need to create an account or log in to post comments to this site.


Click here to browse all 5137 code snippets

Related Posts