Skip to content

jQuery and assumptions…

by chris on June 2nd, 2010

I have been working on a bridge between my PHP and MooTools/jQuery template parsers. So far all has been going well, until I decided to try and load the templates via script tag injection. The MooTools version went swimmingly…

The jQuery version, not so much. It seems that when you do $(‘<script…’).appendTo(‘head’), jQuery assumes you want to get the file with XHR. No questions asked. It doesn’t actually do the XHR request until you append it to the head element (not sure where else it makes this assumption) but the assumption is wrong.

I specifically chose to load the templates with script injection so that the template loading wouldn’t clog up Firebug and could be done from another domain. Thanks jQuery! If you are wondering what worked; it’s actually quite easy to achieve with vanilla JavaScript…

From → Javascript

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS