Last active
December 19, 2015 10:49
-
-
Save danielmackay/5943433 to your computer and use it in GitHub Desktop.
Posting JSON with Knockout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form action="/tasks/saveform" method="post"> | |
| <hidden name="tasks" data-bind="value: ko.toJSON(tasks)"></hidden > | |
| <button type="submit">Save</button> | |
| </form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.save = function() { | |
| $.ajax("/tasks", { | |
| data: ko.toJSON({ tasks: self.tasks }), | |
| type: "post", contentType: "application/json", | |
| success: function(result) { alert(result) } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment