0

in Backbone?

I'm using POST to handle all CRUD operations and I need to know the proper place to set POST key/value pairs.

As an example how would you do this for a Collection fetch() request.

Please take note that I have over-ridden Backbone.Sync to always use POST.

Please understand I've done this for a reason and it will work fine as my server is setup this way for testing purposes.

Thanks.

Here is the over-ridden Sync FYI in Q/A format.

Is it O.K. to re-write Backbone.sync by hard coding in values?

Update

It looks like it just needs to be set to the data property as an obeject literal or query string according to:

http://hayageek.com/jquery-ajax-post/

Strange this info. was not in the jQuery ajax API.

Community
  • 1
  • 1

1 Answers1

0

from the manual

jQuery.ajax options can also be passed directly as fetch options, so to fetch a specific page of a paginated collection: Documents.fetch({data: {page: 3}})

http://backbonejs.org/#Collection-fetch

you may also be interested in backbones emulate HTTP option

If you want to work with a legacy web server that doesn't support Backbone's default REST/HTTP approach, you may choose to turn on Backbone.emulateHTTP. Setting this option will fake PUT, PATCH and DELETE requests with a HTTP POST, setting the X-HTTP-Method-Override header with the true method. If emulateJSON is also on, the true method will be passed as an additional _method parameter.

http://backbonejs.org/#Sync-emulateHTTP

exussum
  • 18,275
  • 8
  • 32
  • 65