This question already has an answer here:
I honestly don't know what is wrong. I write my includes like this:
<script src="http://ift.tt/2eBd7UN"></script>
<script src="http://ift.tt/2aHTozy"></script>
<script src="path/to/source/js/utils.js"></script>
<script src="path/to/source/js/initPage.js"></script>
<script>
myScript(); //uses stuff from the last 2 JS files.
</script>
and myScript executes, EXCEPT for whichever functions in it use jQuery selectors. I tested it all around, and it just shows jQuery doesn't load in those files.
However, if I do
<script src="http://ift.tt/2eBd7UN"></script>
<script src="http://ift.tt/2aHTozy"></script>
<script>
$.getScript("path/to/source//js/utils.js", function(){
$.getScript("path/to/source//js/initPage.js");
myScript();
});
</script>
myScript executes without any problems, the jQuery parts of it included.
My question is:
Is it possible to make the first implementation work somehow? Because $.getScript(), unlike the tags, doesn't initiate caching, and I am too lazy to implement a custom ajax call that does.
Aucun commentaire:
Enregistrer un commentaire