Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#12874 closed bug (notabug)

$.ajax add is not defined

Reported by: [email protected] Owned by: [email protected]
Priority: low Milestone: None
Component: deferred Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by jaubourg)


I am working on a site and I am using backbonejs and requirejs and with r.js I create a bundled js file which contains all my js modularised.

If I make a simple ajax request and I even don't attach any event listener on it I get the following error after I receive the ajax response:

Uncaught ReferenceError: add is not defined

I have made some debugging and it seems that the problem is here:

// First, we save the current length
var start = list.length;
(function add( args ) {
        jQuery.each( args, function( _, arg ) {
                var type = jQuery.type( arg );
                if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
                        list.push( arg );
                } else if ( arg && arg.length && type !== "string" ) {
                        // Inspect recursively
                        add( arg );
})( arguments );

This is in jquery.js at line 997.

It seems that the recursive call of the add method is not working.

This is how I made the ajax request:

        dataType: 'json',
        type: 'post'

Change History (6)

comment:1 Changed 10 years ago by Rick Waldron

Owner: set to [email protected]
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.

comment:2 Changed 10 years ago by dmethvin

Owner: [email protected] deleted
Status: pendingnew


I'm not clear on how this is happening. The parens around the function shouldn't create a new scope? Is this something the r.js optimizer is transforming within the code?

comment:3 Changed 10 years ago by dmethvin

Component: unfileddeferred
Owner: set to [email protected]
Priority: undecidedlow
Status: newpending

comment:4 Changed 10 years ago by jaubourg

Description: modified (diff)

Does this work without using r.js? In which case it's a bug in r.js, not jQuery.

comment:5 Changed 10 years ago by dmethvin

Resolution: notabug
Status: pendingclosed

We haven't received replies on this, and it's not clear how this can be a bug in jQuery. Please reply with some technical details if this still needs to be addressed. If r.js is changing the code it sounds like the transformation is being done wrong.

comment:6 Changed 10 years ago by [email protected]

Sorry, I don't really have time to create a use case. I think it's better if you close this and if I will create a use case I will write a new comment. Sorry again.

Note: See TracTickets for help on using tickets.