Search code examples
javascriptajaxnode.jszombie.js

Get Http error from Ajax triggered by async click event with ZombieJS


So I have a webpage which uses knockout and I have a click handler. Once clicked it fires off an ajax request to an API server which returns a contextual HttpStatus result.

So for example if I was unauthorised I would get a 401 response, if it was ok I would get 200. So the question is based around how can I capture the error in Zombie as the .click("#some-button", function(error) { /* No Error */ }) is returning no error from the callback, so is there some other way to try and catch the http status codes?


Solution

  • From the zombieJS API, you can get the status codes by this method : browser.statusCode.