views:

98

answers:

2

help, I need to change this code to support remote domain access:

document.write(url);
    var http = getHTTPObject();
      http.open("GET", url, true);
      http.onreadystatechange = function() {
          if (http.readyState == 4) {
              parseData(http.responseText);
          }
      }
      http.send(null);
+1  A: 

in your js:

function() goRemote(url) {
  var script = document.createElement("script");
  var script = new Script();
  script.src=url;
  document.body.appendChild(script);
}
function() parseDate(json) {
  // do your fun here.
}

in your returned js:

parseData({"foo": "bar"});
andersonbd1
Actually, HEAD tag can not have "id" attribute in HTML4.01. Instead making your markup invalid and accessing HEAD element by ID, use `getElementsByTagName('head')[0]` (or any kind of selector utility available, such as `$` in jQuery, `$$` in Prototype.js, etc.)
kangax
returned js sample was not valid..
Tom
get element head not working..
Tom
Don't bother messing around with the head, just document.body.appendChild
David Dorward
A: 

this might help you: http://test.getify.com/jXHR/
You will not need to change code if you will use this library.

Eldar Djafarov