How should backbone.js handle a GET request that returns no results? How should backbone.js handle a GET request that returns no results? codeigniter codeigniter

How should backbone.js handle a GET request that returns no results?


Backbone triggers an "error" event on "sync" errors. You can catch the 404 error by creating an error handler function in your view.

this.model.on('error',this.defaultErrorHandler,this);defaultErrorHandler: function(model, error) {        console.log('status', error.status);    }


You can overload the error event in backbone; though it would be better to change the REST response from the server. On no result send back 200 ok with an empty JSON object. Be sure to test for a null object from the server.


True, simply set response to empty, and the status to 200:

$this->response(NULL, 200);