Bug Tracker

Modify

Ticket #9347 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 2 years ago

$.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
Blocking: Blocked by:

Description (last modified by rwaldron) (diff)

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

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

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

comment:2 Changed 2 years ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to wontfix
  • Status changed from new to closed
  • Component changed from unfiled to ajax

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 2 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 2 years ago by timmywil

  • Status changed from closed to reopened
  • Resolution wontfix deleted

comment:5 Changed 2 years ago by timmywil

  • Cc jaubourg added
  • Status changed from reopened to open

comment:6 Changed 2 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 2 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 2 years ago by timmywil

Perhaps something like

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

I think I would like that.

comment:9 Changed 2 years ago by john

  • Keywords 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:10 Changed 2 years ago by rwaldron

  • Description modified (diff)

+0,

comment:11 Changed 2 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 2 years ago by timmywil

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

comment:13 Changed 2 years ago by dmethvin

  • Description modified (diff)

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

comment:14 Changed 2 years ago by john

  • Description modified (diff)

-1, Uhh yeah, that would be bad.

comment:15 Changed 2 years ago by addyosmani

-1

comment:16 Changed 2 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 2 years ago by scott.gonzalez

  • Description modified (diff)

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

comment:18 Changed 2 years ago by rwaldron

  • Keywords 1.7-discuss removed
  • Status changed from open to closed
  • Resolution set to wontfix
  • Description modified (diff)
  • Milestone changed from 1.next to 1.7

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.