self.addEventListener('message', function (e) {
    //console.log("Load");
    load(e.data.url, e.data.data);
    
}, false);

//simple XHR request in pure JavaScript
function load(url, data, callback) {
    var xhr;

    if (typeof XMLHttpRequest !== 'undefined') xhr = new XMLHttpRequest();
    else {
        var versions = ["MSXML2.XmlHttp.5.0",
			 	"MSXML2.XmlHttp.4.0",
			 	"MSXML2.XmlHttp.3.0",
			 	"MSXML2.XmlHttp.2.0",
			 	"Microsoft.XmlHttp"]

        for (var i = 0, len = versions.length; i < len; i++) {
            try {
                xhr = new ActiveXObject(versions[i]);
                break;
            }
            catch (e) { }
        } // end for
    }

    xhr.onreadystatechange = ensureReadiness;
    
    function ensureReadiness() {
        if (xhr.readyState < 4) {
            return;
        }

        if (xhr.status !== 200) {
            return;
        }
        //console.log(xhr.readyState);
        // all is well	
        if (xhr.readyState === 4) {
            //console.log(xhr.responseText);
            self.postMessage(xhr.responseText);
        }
    }

    xhr.open('GET', url, true);

    xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");

    xhr.send(data);
}

//and here is how you use it to load a json file with ajax
//load('data.json', function (xhr) {
//    var result = xhr.responseText;
//});