Skip to content Skip to sidebar Skip to footer

Very Weird Jquery Error

So I had code that was working properly on my site: $('#usr').load('somepage.php',{var1:var1,var2:var2}); But ever since I changed some code in the navigation bar, jQuery has been

Solution 1:

That sounds a lot like you're loading Prototype or MooTools or something as well as jQuery, and so Prototype/MooTools/whatever is taking over the $ symbol.

If that's what's going on, and you need the other library, you can use jQuery.noConflict(). Then you either use the symbol jQuery instead of $ for your jQuery stuff, or you put all of your jQuery code into a function that you pass into jQuery.noConflict and accept $ as an argument, like so:

// Out here, $ !== jQuery
jQuery.noConflict(function($) {
    // In here, $ === jQuery
});

Or you can just do it yourself:

// Out here, $ !== jQuery
jQuery.noConflict();
(function($) {
    // In here, $ === jQuery
})(jQuery);

ready also passes the jQuery object into the function, if you're already using ready.

Post a Comment for "Very Weird Jquery Error"