Return to Snippet

Revision: 18640
at October 5, 2009 13:50 by johnloy


Initial Code
function import(url)
{
    var req = new XMLHttpRequest();
	var isSuccessful = function() {
		try {
            return ( req.status >= 200 && req.status < 300 ) || req.status == 304 || navigator.userAgent.indexOf("Safari") >= 0 && typeof req.status == "undefined";
        } catch(e){}
        return false;
	}
    req.open('GET', url, true);
	req.onreadystatechange=function() {
		if ( req.readyState == 4) {
			if(isSuccessful()) {
				eval.call( window, req.responseText );
			}
		}
	}
	req.send();
};

Initial URL

                                

Initial Description

                                

Initial Title
import function to synchronously load external javascript files

Initial Tags
ajax, javascript, textmate

Initial Language
Other