Uncaught TypeError undefined is not a function anonymous function

I am new to JS, and have bumped into a problem. Album results in an error, which is listed below.

Uncaught TypeError: undefined is not a function script.js?ver=1.0:12
(anonymous function) script.js?ver=1.0:12
n.extend.each jquery.js?ver=1.11.0:1
n.fn.n.each jquery.js?ver=1.11.0:1
initialise script.js?ver=1.0:12
jQuery.ajax.success loader.js?ver=1.0:9
j jquery.js?ver=1.11.0:1
k.fireWith jquery.js?ver=1.11.0:1
x jquery.js?ver=1.11.0:1
bjquery.js?ver=1.11.0:1

Upon reloading the page however, everything works. What can be the problem?

Read More

I have included a script.js code segment (that can also be seen through developer tools) that seems to be problematic. Please let me know if I need to include my .php file.

/*---------------------------------------------- 
               F L E X S L I D E R
------------------------------------------------*/
jQuery(content+' .slider').each(function(index){
    var thisid = jQuery(this).attr('id');   
        jQuery("#"+thisid+" .flexslider").flexslider({ - This line is causing error
        controlsContainer: "#"+thisid,
        animation: "fade",
        slideshowSpeed: 7000,
        animationDuration: 600,
        slideshow: false,
        directionNav: true,
        controlNav: true,
        smoothHeight: true,
        touch: true,
        video: true,
        randomize: false
    }); //end flexslider
});

Related posts

Leave a Reply

1 comment

  1. The reason you’re getting line 12 is because the script.js file is being “compressed” by removing all unnecessary white space. If you use the “pretty print” icon ( looks like this {} ) in the lower left corner of the JS source view in the Developer tools window you’ll actually see that it is the following code giving you problems:

    jQuery("#" + thisid + " .flexslider").flexslider({controlsContainer: "#" +
    thisid,animation: "fade",slideshowSpeed: 7000,animationDuration: 600,
    slideshow: false,directionNav: true,controlNav: true,smoothHeight: true,
    touch: true,video: true,randomize: false});
    

    The cause of this is most likely that the flexslider function is trying to be called before it’s actually loaded from the flexslider script. Ensure that the flexslider script is loaded before the function is called and this should fix your problem.