I ran into Uncaught TypeError: undefined is not a function when I was trying to include a jQuery plugin (fancyBox image viewer plugin).
My page has 2 divs which use php require codes. I have been testing, the jQuery script works fine when there are no php codes, but once I add the php codes, jQuery no longer works, it produced Uncaught TypeError: undefined is not a function. The php codes work fine.
The php codes are:
<?php
require($DOCUMENT_ROOT . "#sub-html/menu-nav.html");
?>
and
<?php
require($DOCUMENT_ROOT . "#sub-html/footer.html");
?>
This is the jQuery script to call the plugin:
$(document).ready(function() {
$(".fancybox-thumb").fancybox({
(Uncaught TypeError: undefined is not a function - this is where the error is)
prevEffect : 'none',
nextEffect : 'none',
closeBtn : true,
arrows : true,
nextClick : true,
helpers : {
title : {
type : 'inside'
},
thumbs : {
width : 50,
height : 50
}
}
});
});
I save this file in .html. I think this error is something specific to how this plugin is compatible when used with other php codes, as in another page, with same structure, different plugin works fine. I have tried putting the jQuery script in the head and body sections of html, both did not work, if that matters.
I searched around, the majority of this error is caused when there are more than 1 jQuery libraries included in the file. Mine has 1 library only. So I think that reason can be crossed out.
Please help me with this. Thank you very much.
P/S: I have figured out the reason why I got this error. I will post my answer after the 8-hour time frame. Thank you for taking time to help me.