I agree with pretty much everything Julian said. And while I don't have a problem with $.get(url, onSuccess, onError), I can see how this isn't "jQuery-like".
Right now, $.get returns an XmlHttpRequest object. What if that object were extended a bit? $.get(url, callback).error( onError ) Or, heck, go even crazier.... all $.ajax calls return a jQueryAjax Object (that responds to everything XmlHttpRequest objects do... for backwards compatibility)... that could lead to $.get(url).success( callback ).error( callback ). Interestingly, this would lead to the ability to cleanly request a resource, then define how you want to handle it later on, even after it's already come back. That's at least a *little* more jQuery-like :) _jason On Nov 9, 9:49 am, Julian Aubourg <aubourg.jul...@gmail.com> wrote: > OK and well I guess, but I'll go back to my original statement too then: > "simple cases don't protect from temporary connection and/or server > shutdowns, do they?". Like I said, I will use $.ajax anyway, but let me > re-iterate that simple in design (rather in signature here) does not mean > suitable for simple cases. The OP problem is quite clear: for "serious work" > (ie: in real world production), error handling is mandatory because no > matter how simple the ajax call, error can (and will) occur. I'm afraid the > simple cases you're refering to are nothing more than proof of concepts and > I personally don't use jQuery to do prototypes but real world web sites. > > That being said, the current status of $.get and $.post also pushes > developers into ignoring errors altogether which makes for plugins you have > to modify (or just plain rewrite) for production use (sadly talking from > experience here). > > Finally, handling error cases with $.ajaxError in that case is like crushing > an egg with a grand piano. > > And before anybody jumps at my throat, let me say again that I mean no > disrespect: I admire the work you guys put into jQuery and I shudder to > imagine how I would develop without this fantastic toolbox but, as of today, > $.get and $.post are not "write less, do more", they are "write less, do > half the work". > > But well, what do I care? I never use them anyway ;) > > 2009/11/9 John Resig <jere...@gmail.com> > > > Ok, so I go back to my original statement: "Really the get and post > > methods are meant to be simple cases, everything else should be > > tackled with the ajax method." > > > --John > > > On Mon, Nov 9, 2009 at 4:48 PM, Julian Aubourg <aubourg.jul...@gmail.com> > > wrote: > > > Well, to be honest, I never ever use $.get or $.put (or $.getJSON). The > > main > > > reason is that there is no error callback which, in my opinion, makes > > them > > > completely useless in any production environment. > > > > Now I understand the convention being broken argument, but the two > > callback > > > solution: > > > - does not break current code, ever, > > > - does not necessitate jQuery to create a special error callback that > > will > > > redirect to the dual callback function, > > > - does not necessitate branching in user code. > > > > I dunno, but for helper functions, I'd be willing to sacrifice some api > > > purity and have them really useful yet backward compatible. But, then > > again, > > > I never had the responsibility of anything that's became as huge as > > jQuery, > > > so... > > > > 2009/11/9 John Resig <jere...@gmail.com> > > > >> > Wouldn't it still break some scripts that actually expect the data > > never > > >> > to > > >> > be undefined? > > > >> As I mentioned before - the application would just break in a > > >> different way. Normally it would break in that the result would never > > >> come in - now it would throw an exception (again, that's assuming that > > >> if they're trying to do something directly with the object - a more > > >> likely result is seeing "null" outputted somewhere). > > > >> > Why not the following: > > > >> > $.get("someurl", function(data) { > > >> > // got results > > >> > }, function(errorMessage) { > > >> > // got error > > >> > }); > > > >> > That way, actual scripts behave as usual and new ones can provide an > > >> > error > > >> > callback. > > > >> > Thoughts? > > > >> I'm not a huge fan of this - having dual functions being passed in as > > >> arguments is messy and against the current jQuery conventions. I feel > > >> like if you're passing in so many functions why not just use $.ajax > > >> and be done with it? Especially since $.ajax is so much more explicit > > >> any way. > > > >> Either we should find a simple solution (like what I proposed) or do > > >> no change at all. > > > >> --John > > > >> -- > > > >> You received this message because you are subscribed to the Google > > Groups > > >> "jQuery Development" group. > > >> To post to this group, send email to jquery-...@googlegroups.com. > > >> To unsubscribe from this group, send email to > > >> jquery-dev+unsubscr...@googlegroups.com<jquery-dev%2bunsubscr...@googlegroups.com> > > . > > >> For more options, visit this group at > > >>http://groups.google.com/group/jquery-dev?hl=en. > > > > -- > > > > You received this message because you are subscribed to the Google Groups > > > "jQuery Development" group. > > > To post to this group, send email to jquery-...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > jquery-dev+unsubscr...@googlegroups.com<jquery-dev%2bunsubscr...@googlegroups.com> > > . > > > For more options, visit this group at > > >http://groups.google.com/group/jquery-dev?hl=en. > > > -- > > > You received this message because you are subscribed to the Google Groups > > "jQuery Development" group. > > To post to this group, send email to jquery-...@googlegroups.com. > > To unsubscribe from this group, send email to > > jquery-dev+unsubscr...@googlegroups.com<jquery-dev%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/jquery-dev?hl=en. -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.