On Mon, Sep 7, 2009 at 5:35 PM, Daniel Friesen<[email protected]> wrote:
>
> I don't see how passing you all the information is "inflexible", on
> the contrary I would find writing a handler for a code and realizing
> there was another status code that needs the same handling to be what
> is really inflexible.
then they should call the same handler. what does that have to do
with inflexibility? and even there:
options = { 404: handlerA, 405: handlerA, ... };
is nicer than:
options = { error: function(xhr) {
switch (xhr.statusCode) {
case 404:
case 405: handlerA(xhr); break;
}
}, ... };
> If you have different handing based on different status codes then
> break up your handlers by what they do into diferent functions and
> simply write a switch statement that calls the relevant function. I
> don't see how that isn't flexible as the definition of flexibility in
> this case is the ability to bend the code to do something slightly
> different (like have a second status code share the handler of
> another) with easev(like adding a new case line into a switch).
they already are in different functions, and a switch statement is
simple to write. no argument. you see flexibility in terms of you
typing code. i am looking at it in terms of either myself type *or
other code composing an options object*. This is why i speak of
flexibility. More than one way to put together the code/options for
an ajax call.
> ~Daniel Friesen (DanTMan, Nadir Seen Fire) [http://daniel.friesen.name]
>
> On 7-Sep-09, at 3:24 PM, Nathan Bubna <[email protected]> wrote:
>
>>
>> On Mon, Sep 7, 2009 at 12:08 PM, John Snyders<[email protected]>
>> wrote:
>>>
>>> I would like to add my opinion.
>> ...
>>> I do not think individual callbacks for each status code are a good
>>> idea.
>>
>> Why?
>>
>> Do you not use XHR with services where you need to do different things
>> depending on which 4xx code (for example) you receive back? Or do you
>> just prefer to organize your branching as a switch/case or if/elseif
>> within an error callback?
>>
>> In my current app, fairly different handlers are required for say, 401
>> than 405 or 404, and embedding the branching within switch/case or
>> if/elseif is ugly and inflexible. This also happens to be a feature
>> which would be much simpler and better to implement in the core ajax
>> code than in a plugin.
>>
>> >
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---