I've thought about your post some more and I think this might actually
be ok. Considering that right now the only callback that is fired is
the success callback we can safely assume that people who are using
this method don't actually care about the error state - thus if we
pass in the normal
Another option could be a modified error callback and actually have it
work like this:
$.get(someurl, function(data, errorMessage){
if ( data ) {
// got results
} else {
// got error
alert( errorMessage );
}
});
Thoughts on this?
This one looks cleaner to me; and it
Wouldn't it still break some scripts that actually expect the data never to
be undefined?
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
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
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
Couldn't you just use the .ajaxError() method in conjunction with
$.get or $.post? That seems to work for me.
http://docs.jquery.com/Ajax/ajaxError#callback
--Karl
On Nov 9, 2009, at 10:48 AM, Julian Aubourg wrote:
Well, to be honest, I never ever use $.get or $.put (or $.getJSON).
The
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
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
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,
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,
10 matches
Mail list logo