As simple as they should be I always wondered why $.get (and $.getJSON) and
$.post don't have the option to provide an error callback as a third
parameter. I mean, simple cases don't protect from temporary connection
and/or server shutdowns, do they? With the current success callback only
design, it gives library users the illusion nothing can go wrong with $.get
and $.put.

2009/11/8 John Resig <jere...@gmail.com>

> Making that change as-is would definitely seem to break code. Really
> the get and post methods are meant to be simple cases, everything else
> should be tackled with the ajax method.
>
> --John
>
> On Sunday, November 8, 2009, Mr Speaker <mrspea...@gmail.com> wrote:
> > The $.post and $.get are really handy, but seem limited in their use
> > for serious work because you can't tell if they fail (can you? I mean,
> > besides the global error handler?).
> >
> > I couldn't find any discussion on this, it would be useful if you
> > could just call the same callback method for either success or error
> > and let the user play with the result:
> >
> > post: function( url, data, callback, type ) {
> >         ...
> >         return jQuery.ajax({
> >                 type: "POST",
> >                 url: url,
> >                 data: data,
> >                 success: callback,
> >                 error: callback,  <-- same function
> >                 dataType: type
> >         });
> >
> > This would be especially useful for $.post where it's usually pretty
> > important that you know that an update has occurred. In the
> > documentation the callback code has this comment:
> > // NOTE: Apparently, only "success" is returned when you make
> > // an Ajax call in this way. Other errors silently fail.
> >
> > So I guess there is a reason for not doing this... it would break
> > existing code for people who just checked for ANY return value, and I
> > suppose it complicates the simple $.post function a little - but it
> > would give these helper functions more "real world" uses.
> >
> > --
> >
> > 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.
> >
> >
> >
>
> --
> --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.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to