c# - Pass data in a .getJSON. Possible? How? -
i'm doing app , got select user can choose different teams. each team contains couple of patients. save chosen team data-bind selectedoptions , stores option observable called 'selectedteam'.
i'm receiving list of patients calling
self.searchpatients = function () { $.getjson("/api/api/getpatients", function (data) { ko.mapping.fromjs(data, {}, self.patients); }); }; self.searchpatients();
back @ apicontroller got method asks db patients. calls takes different arguments, 1 of them being team search from.
my question how pass observable 'selectedteam' apicontroller, convert string pass db call.
thx
assuming server method looks follow :
[httpget] public object getpatients(string team) { // return patients }
you should use javascript :
self.searchpatients = function () { $.getjson("/api/api/getpatients", { team: self.selectedteam() }, function (data) { ko.mapping.fromjs(data, {}, self.patients); }); };
because self.selectedteam observable can't send server.what want send value. that's why need 'call' observable.
self.selectedteam() // returns value of observable.
i hope helps.
Comments
Post a Comment