0

I have the following block of javascript in my webpage:

console.log($.ui);

$("#schoolBagBtn").click(function(){
    $.ajax({
        url:"./php/get.php",
        success: function(){
            console.log($.ui);
        }
    });
});

And the result of running this javascript is the first $.ui is defined as a jQuery object and the one which after calling the ajax is undefined. And I need it to be a object too.

Can anyone help?

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
  • possible duplicate of [How come $(this) is undefined after ajax call](http://stackoverflow.com/questions/9827291/how-come-this-is-undefined-after-ajax-call) – Alexandru Chichinete May 26 '14 at 14:35
  • 2
    @kikyalex - I don't think this is a duplicate of that question. – Jared Farrish May 26 '14 at 14:36
  • 1
    @T.J.Crowder Thanks a lot, you're right. After reading your comment, I found that that I load another jQuery plugin because of using css framework - bootstrap. After delete it, it works !!! Thanks a lot!!! ^^ – user3344910 May 26 '14 at 15:09

1 Answers1

1

The most likely issue is that something you haven't shown is replacing/updating the $ variable. For instance, you might have a second script tag after the above that includes jQuery again. The second load of jQuery will replace the first, and that means any plugins (like jQuery UI) attached to the first one disappear.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875