AJAX-enabled WCF Service :: Round tripping
From the last post; we have realized that for a typical CRUD / Round tripping implementation; we need “something” that can do JSON to DOM and DOM to JSON conversion so that we can send and receive JSON data over the wire using the jQuery!
By default; AJAX enabled WCF Service; doesn’t send the exception detail back to client; to enable it for debugging during development; make the following changes in web.config
Lets add an Update method in our WCF Service as well; I have coded very minimally
Please note; the use of “notes” node in the viewModel; this is used in foreach data template, ko.applyBindings does the binding magic. To learn more about Knockout; visit their site. There are tons of examples! I am also attaching a MSDN Channel 9 video below as well!
- Update: You can use ko.toJSON(viewModel) instead of JSON.stringify(ko.toJS(viewModel))
For the sake of simplicity; I havnt implemented Create and Delete operations; but with Knockout its all client side thing; to delete some item from the array we can simply delete it from the viewModel and to create a new item; we can add it into it and write the code at the server side accordingly.