javascript - Knockout.js posting a form -


what simplest method of posting form server when clicking submit button using knockout.js?

this have not posting. broken saveform function?

// here's data model save option var self = this; var viewmodel; $.getjson('@url.content("~/api/mydata")', function (data) {     viewmodel = ko.mapping.fromjs(data);     self.save = function (form) {         alert("could transmit server");     };      viewmodel.saveform = function () {         var jsondata = ko.mapping.tojson(viewmodel);         $.ajax({             type: "post",             url: '@url.content("~/api/mydata")',             data: jsondata         });     };     ko.applybindings(viewmodel); });  <button type="submit">save</button> 

probably worth putting line

debugger; 

before

viewmodel = ko.mapping.fromjs(data); 

and checking happens viewmodel in firebug. "viewmodel = ko.mapping.fromjs(data);" replace in viewmodel json loading. includeds function saveform


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -