Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread John Resig
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread Scott Sauyet
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread Julian Aubourg
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread John Resig
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread Julian Aubourg
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread Karl Swedberg
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-09 Thread Julian Aubourg
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

[jquery-dev] Calling callback in $.post $.get on error

2009-11-08 Thread Mr Speaker
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

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-08 Thread John Resig
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,

Re: [jquery-dev] Calling callback in $.post $.get on error

2009-11-08 Thread Julian Aubourg
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,