JQuery fix for error "Digging TypeError: $ is not a function"

My code is:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://someothersite.com/external.js"></script> 

external.js:

 $("head").append(unescape("")); 

Unfortunately, I get the following error when I include my external script:

Uncaught TypeError: $ is not a function

How to fix it? Please keep in mind that I cannot edit an external Javascript file as a third party.

+5
source share
3 answers

He used an old version of jQuery.

I updated the version and this solved the problem for me.

Woop!

+5
source

Use the following statement in the JS file.

 jQuery(document).ready(function($){ // jQuery code is in here }); 

After declaring the above operator, you can use the $ sign.

+19
source

I think the problem is that external javascript was loaded first before loading jquery. To solve this requirejs task, follow this link to use http://requirejs.org/docs/api.html

+2
source

Source: https://habr.com/ru/post/1234259/


All Articles