stackp / promisejs

Lightweight javascript implementation of promises.
443 stars 127 forks source link

return always ajax status and content #7

Closed posativ closed 10 years ago

posativ commented 11 years ago

When I build REST applications I often use HTTP status codes as semantic parameter, e.g. 201 for a created object that I will return as json. This is completely valid HTTP/1.1 [1].

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

stackp commented 10 years ago

Hi posativ, you're absolutely right. I still wanted to keep the if (error) {...} statement, so the xhr object is now passed as a third argument to the callback. That way, the status code and other informations (e.g. response headers) can be read. See the updated README for an example.

Cheers, and thank you !