#12874 closed bug (notabug)
$.ajax add is not defined
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | deferred | Version: | 1.8.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
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' });
Change History (6)
comment:1 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
Owner: | [email protected]… deleted |
---|---|
Status: | pending → new |
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?
comment:3 Changed 10 years ago by
Component: | unfiled → deferred |
---|---|
Owner: | set to [email protected]… |
Priority: | undecided → low |
Status: | new → pending |
comment:4 Changed 10 years ago by
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
Resolution: | → notabug |
---|---|
Status: | pending → closed |
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
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.
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.