Posted By

1man on 03/14/07


Tagged

ajax xml domain security json


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

korzhik
umang_nine
jschilling
wirenaught


Ajax Insert Dynamic "script" into "head"


 / Published in: JavaScript
 

Part of the script tag hack. Allows you to create a script tag on the fly from a url. The url could be a file containing info such as JSON or XML. Used in Ajax for crossing domains.

  1. function getScript(url){
  2. var scriptTag = document.createElement("script");
  3. scriptTag.setAttribute("type", "text/javascript");
  4. scriptTag.setAttribute("src", url);
  5. document.getElementsByTagName("head")[0].appendChild(scriptTag);
  6. }

Report this snippet  

You need to login to post a comment.