O'Reilly logo

Backbone.js Essentials by Jeremy Walker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Server-side actions

Once we've filled a Model class with data, we might not want to lose that data, and that's where the AJAX features of Model come into play. Every Model has three methods to interact with the server, which can be used to generate four types of HTTP requests, as shown in the following table:

Method

RESTful URL

HTTP method

Server action

fetch

/books/id

GET

retrieves data

save (for a new Model)

/books

PUT

sends data

save (for an existing Model)

/books/id

POST

sends data

destroy

/books/id

DELETE

deletes data

The sample URLs in the preceding table are what Backbone will generate by default when it tries to perform any of the three AJAX methods. Backbone works best with a set of server-side ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required