It depends on how the server is set up, to some degree. Backbone is designed to work with RESTful services. I think you already looked through it, but for completeness here is the documentation for save
: http://backbonejs.org/#Model-save
save
and fetch
and destroy
delegate to Backbone.sync
: http://backbonejs.org/#Sync
And AJAX queries are sent by default using jQuery.ajax: http://api.jquery.com/jQuery.ajax/
or, if you can't use jQuery, Backbone.ajax
: http://backbonejs.org/#Sync-ajax
You want to make sure the parameters you are sending match what the server is looking for (that the keys and values you need match up), and that it can accept a JSON object, which should be a normal thing. And then you would want models to be returned as JSON objects.
But even if the server doesn't work that way, you can customize everything in Backbone to match what you need. You can customize the ajax request, you can customize the toJSON
method which preps the model or collection to be sent via AJAX (docs here), you can customize the parse
method which handles the response from the server (docs here).
The defaults in Backbone are very simple and the server doesn't have to do much to work with it, but you can easily basically rewrite how Backbone works if you need to.