add ajax 'target' option for triggering ajax events non-globally

add ajax 'target' option for triggering ajax events non-globally


<div id="a"></div>
<div id="b"></div>
$('#b').ajaxStart(function(e) { console.log('ajax started! and the
target was '+e.target+'?!?'); });
$('#a').load('foo');
This was really unintuitive and surprising to me. Given the way ajax
events are triggered currently, there is no way to distinguish what
element the load() call happened on. This creates limitations for
both my current application and my plugins (namely, loading and rest).
I would love to have a 'target' option for $.ajax calls that would
cause the ajax events to be triggered as normal, bubbling custom
events on the specified target element, rather than always be global.
And of course, i think load() should pass the target option by
default.
Does that make sense? Would that break too many things? I'm willing
to file the bug and patch, but i wanted feedback, particularly to see
if i was missing some key reason for things being the way they are
first.
This came out of here:
http://stackoverflow.com/questions/1201512/jquery-ajax-events-called-on-every-element-in-the-page-when-only-targeted-at-one/1202235#1202235
which was also posted here:
http://groups.google.com/group/jquery-en/browse_thread/thread/6613a7f4972600b6