Bug Tracker

Opened 12 years ago

Closed 12 years ago

#7640 closed enhancement (worksforme)

Add load_send, load_complete, load_success and load_error event trigger on the core onload function

Reported by: Christophe KINNE <[email protected]…> Owned by:
Priority: low Milestone: 1.5
Component: ajax Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:


On some DOM elements I needed to use a generic function to show a "loading..." div in the element during the load operation and hide it when the load operation has finished.

As I have several different load operation I really needed a common way to trigger operations on the different states of the load action.

But if the global ajax event handlers .ajaxSend() and .ajaxComplete() are good for listeners, I was unable to use them for triggering a simple event on the element on which the load is done.

So i added 4 simple triggers at each step of the ajax request in the onload function. They work nicely I use them with .bind() and .live() without any problem.

I've seen some post on the forums of other people who wanted to do the same things so here is my (very) little patch for the 1.4.2 version, if you want to include it.

<               self.trigger('load_send');
<                               self.trigger('load_complete');
<                                       self.trigger('load_success');
<                               else { self.trigger('load_error'); }

Change History (3)

comment:1 Changed 12 years ago by jitter

Component: unfiledajax
Owner: set to Christophe KINNE <[email protected]…>
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project by suggesting an enhancement. I think the granularity of control available with the present ajax events is fine enough and would be hesitant to add more events (trade-off between speed and more control).

Maybe I just didn't fully understand what you intend to do, but can't you just use the existing ajax events and the context option to achieve what you describe? test case which shows how to reuse the same code for different DOM elements (does what I think you described).

Please report back if this example is able to handle the use cases you were thinking about. Or explain more in detail the possible use cases and how this example fails to solve them.

comment:2 Changed 12 years ago by jitter

Owner: Christophe KINNE <[email protected]…> deleted
Status: pendingnew

comment:3 Changed 12 years ago by jitter

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.