Skip to main content

Bug Tracker

Side navigation

#12874 closed bug (notabug)

Opened November 09, 2012 11:38AM UTC

Closed December 05, 2012 01:54AM UTC

Last modified December 05, 2012 05:44PM UTC

$.ajax add is not defined

Reported by: mt.norbert@gmail.com Owned by: mt.norbert@gmail.com
Priority: low Milestone: None
Component: deferred Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

Hi,

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
jQuery.Callbacks.self.add.firingLength
jQuery.extend.each
e
jQuery.Callbacks.self.add
jQuery.extend.Deferred.promise.always
jQuery.extend.ajax.jqXHR.statusCode
done
jQuery.support.ajax.jQuery.ajaxTransport.send.callback

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:

$.ajax(baseUrl+'query',{
	data:form.serialize(),
	dataType: 'json',
	type: 'post'
});
Attachments (0)
Change History (6)

Changed November 13, 2012 04:23PM UTC by rwaldron comment:1

owner: → mt.norbert@gmail.com
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.

Changed November 24, 2012 03:19PM UTC by dmethvin comment:2

owner: mt.norbert@gmail.com
status: pendingnew

https://github.com/jquery/jquery/pull/1028

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?

Changed November 24, 2012 03:21PM UTC by dmethvin comment:3

component: unfileddeferred
owner: → mt.norbert@gmail.com
priority: undecidedlow
status: newpending

Changed November 29, 2012 06:05PM UTC by jaubourg comment:4

description: Hi, \ 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 \ jQuery.Callbacks.self.add.firingLength \ jQuery.extend.each \ e \ jQuery.Callbacks.self.add \ jQuery.extend.Deferred.promise.always \ jQuery.extend.ajax.jqXHR.statusCode \ done \ jQuery.support.ajax.jQuery.ajaxTransport.send.callback \ \ 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: \ $.ajax(baseUrl+'query',{ \ data:form.serialize(), \ dataType: 'json', \ type: 'post' \ }); \ Hi, \ \ 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 \ jQuery.Callbacks.self.add.firingLength \ jQuery.extend.each \ e \ jQuery.Callbacks.self.add \ jQuery.extend.Deferred.promise.always \ jQuery.extend.ajax.jqXHR.statusCode \ done \ jQuery.support.ajax.jQuery.ajaxTransport.send.callback \ }}} \ \ I have made some debugging and it seems that the problem is here: \ {{{#!js \ // 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: \ {{{#!js \ $.ajax(baseUrl+'query',{ \ data:form.serialize(), \ dataType: 'json', \ type: 'post' \ }); \ }}}

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

Changed December 05, 2012 01:54AM UTC by dmethvin comment:5

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.

Changed December 05, 2012 05:44PM UTC by mt.norbert@gmail.com comment:6

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.