Pass statusText through instead of "normalizing" it
|Reported by:||Peter Kline <pkline@…>||Owned by:||jaubourg|
When creating an ajax request, jQuery normalizes the server response text (statusText) to "success", "error", etc. This hasn't always been the case - in a 1.4.x version we used, it passed this through.
I understand the normalization rationale, but I think it's short-sighted. Rather than returning basic error messages in an HTML/XML/JSON body (and then having to parse it), it's a lot easier to return small messages in the HTTP header than creating content (HTTP/1.0 406 Subject Cannot Be Blank, HTTP/1.0 204 No Search Results Found). In our specific case, these are often validation messages for the user.
I could return text/plain error messages, but again - that's more work and code on the server and traffic on the wire where not necessary.
On the flip side, jQuery already allows you to pass functions for error and success, as well as per status code, and it preserves the code itself.
If you wish to preserve the normalized text, I'd be happy to convert my code to access to differently named property (httpHeaderText?) with the preserved text (though I'd prefer to keep my code the way it is).
Change History (7)
comment:2 Changed 5 years ago by jaubourg
- Component changed from unfiled to ajax
- Milestone changed from None to 1.next
- Owner set to jaubourg
- Priority changed from undecided to low
- Status changed from new to assigned
comment:6 Changed 5 years ago by jaubourg
- Resolution set to fixed
- Status changed from assigned to closed