REST API:
If you need to access my REST API, you can do so by sending a GET request to the following URL:
http://localhost/Project/index.php/rest/resource/car
This will retrieve all the data in the table in JSON format. Additionally, you can get specific data for a car with a particular carId using this URL:
http://localhost/Project/index.php/rest/resource/car/carId/2
.
Backbone Integration:
this.mycar.fetch({
data: { 'carId': '1' },
success: function () { ...
When using the above code in Backbone, it generates a request like
http://localhost:7070/Project/index.php/rest/resource/car?carId=1
, which doesn't match my REST API requirements. How can I modify it?
Edit: Model and Collection Setup:
var Car = Backbone.Model.extend({
urlRoot: ROOT + 'car',
idAttribute: 'carId'
});
var Cars = Backbone.Collection.extend({
model: Car,
url: ROOT + 'car',
})