0

I'm using jQuery 1.10.2 and I'm getting the following error regarding the use of getScript. I load jquery, then call a JS file that contains this code. I even use an alert with the version of jQuery right before getScript is called so that I know it is loaded.

Uncaught TypeError: Cannot call method 'getScript' of undefined

Here is the code

$.noConflict();
jQuery(document).ready(function ($) {   
    load_scripts();
});

function pause_for_jquery(){
    setTimeout(load_scripts, 50);
}


function load_scripts(){
    if (!window.jQuery) {
        pause_for_jquery();
    }
    else{
        alert(jQuery.fn.jquery); //this alert works and displays '1.10.2'
        $.getScript("url here", function() {});
    }
 }
2
  • 1
    Why do you wonder that $ is undefined if you have used $.noConflict()? Commented Jan 15, 2014 at 0:01
  • @Bergi: I think implied in this question is that the OP doesn't really understand what $.noConflict() really does, or why it's used. Commented Jan 15, 2014 at 0:08

1 Answer 1

5

The $.noConflict(); deregisters the $ object. You will need to use the longer jQuery() form:

jQuery.getScript("url here", function() {});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.