Bug Tracker

Opened 8 years ago

Closed 8 years ago

#9347 closed enhancement (wontfix)

$.load don't inherit from $.ajax

Reported by: adrien.dupuis@… Owned by:
Priority: low Milestone: 1.7
Component: ajax Version: 1.6.1
Keywords: Cc: jaubourg
Blocked by: Blocking:

Description (last modified by Rick Waldron)

The $.load() function return this. The $.ajax() request build inside the $.load() can't be accessed for, as example, .abort(). By changing

  • jQuery.ajax({

+ return jQuery.ajax({

  • return this;

$.load could be a true $.ajax shorthand.

Change History (18)

comment:1 Changed 8 years ago by adrien.dupuis@…

I mean minus signs, not bullets (diff patch style).

comment:2 Changed 8 years ago by timmywil

Component: unfiledajax
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

load is different in that it is not $.load, but $.fn.load. Generally, functions on the prototype should return the current jQuery instance.

comment:3 Changed 8 years ago by ajpiano

I'm sort of inclined to agree with the OP that there should be some way to access the Deferred associated with a given $.fn.load call - perhaps something similar to how we are able to do so for animations now?

comment:4 Changed 8 years ago by timmywil

Resolution: wontfix
Status: closedreopened

comment:5 Changed 8 years ago by timmywil

Cc: jaubourg added
Status: reopenedopen

comment:6 Changed 8 years ago by dmethvin

This seems like an exceptional case, if it can't be done with one line of code or less I'd prefer we just let people use their own wrapper around $.ajax. #nobloat

comment:7 Changed 8 years ago by jaubourg

I thought about it back when I was working on fn.promise. Fact is you can do element.promise( "someCategory" ). For instance, by default element.promise() is equivalent to element.promise( "fx" ). It's just a question of adding the _mark/_unmark calls where needed.

Dunno if it's that useful though... should we tag this as an 1.7 enhancement proposal?

comment:8 Changed 8 years ago by timmywil

Perhaps something like

$(elem).load().promise("ajax")

I think I would like that.

comment:9 Changed 8 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:10 Changed 8 years ago by Rick Waldron

Description: modified (diff)

+0,

comment:11 Changed 8 years ago by jaubourg

-1, The more I think about it, the less I like this. If you want to do this, use ajax directly.

comment:12 Changed 8 years ago by timmywil

-1, per my initial reaction + jaubourg's comment

comment:13 Changed 8 years ago by dmethvin

Description: modified (diff)

-1, Rare cases may need additional code. No shame in that.

comment:14 Changed 8 years ago by john

Description: modified (diff)

-1, Uhh yeah, that would be bad.

comment:15 Changed 8 years ago by addyosmani

-1

comment:16 Changed 8 years ago by ajpiano

Description: modified (diff)

+1 I don't see why there shouldn't at least be a mechanism to get at the promise from a $.fn.load...

comment:17 Changed 8 years ago by scottgonzalez

Description: modified (diff)

-1, .load() is very much a convenience method, use $.ajax if you need more control

comment:18 Changed 8 years ago by Rick Waldron

Description: modified (diff)
Keywords: 1.7-discuss removed
Milestone: 1.next1.7
Resolution: wontfix
Status: openclosed
Note: See TracTickets for help on using tickets.