loading js dynamically with jquery
I'm conditionally loading a script if the browser is IE8. I'm using jquery's .getScript function because I need to run somethi开发者_如何转开发ng after the script is loaded. The problem is in the format of the URL. I've got it working when downloading the script that's on my hard drive directory but I can't get it to work when loading the script from a site.
This is what I have, I'm sure it's a simple fix but I'm not getting it to work:
$.getScript("https://github.com/malsup/corner/blob/master/jquery.corner.js", function () {
//does something here
});
Thanks for your fix.
The problem is that you are requesting the actual formatted github page ... so you get back html..
use
$.getScript("https://raw.github.com/malsup/corner/master/jquery.corner.js", function () {
//does something here
});
(changed the url to the correct one..)
There is a link Raw
on the heading bar above the formatted code. Click it to get to the raw file..
The safe url is http://malsup.github.com/jquery.corner.js
精彩评论