Callum Bond
Callum Bond

Reputation: 1

TypeError: $ is not a function (Magnific Popup)

I'm a newbie to web dev, so please stick with me. I know this question has come up a lot (or a similar deviation), but after a couple of hours of searching I have not found an answer that works for me.

I've made sure the JQuery file is loaded first, and tried multiple versions to no avail. Whenever I try to load the Magnific Popup script, I get (TypeError: $ is not a function) on line 50. I've had a look and tried to change $ to JQuery to no avail, so it's back to normal now.

Here's the Magnific Popup code block:

var mfp, 
    MagnificPopup = function(){},
    _isJQ = !!(window.jQuery),
    _prevStatus,
    _window = $(window), <<<<<< ERROR HERE
    _document,
    _prevContentType,
    _wrapClasses,
    _currPopupType;

And the relevant html:

<head>
    <link rel="stylesheet" href="css/magnific-popup.css">
</head>
<body>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.magnific-popup.js"></script>
</body>

Upvotes: 0

Views: 10972

Answers (2)

Khuram
Khuram

Reputation: 1850

Try to load your jquery file from your own (local) machine. Hopefully, this will work well. Also, it would be helpful for me if you please let me know that you are not getting 404 for the JQuery file from the CDN.

Upvotes: 0

Sreejith
Sreejith

Reputation: 166

looks like its not picking your jquery library from CDN..

make sure that you have the network in your system or have access to jquery CDN url

if all above is fine then you try with http in CDN url like below. this is working for me

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Upvotes: 1

Related Questions