KnockoutJS, updating ViewModel after ajax call

前端 未结 2 1409
[愿得一人]
[愿得一人] 2021-01-31 23:04

I am using Knockout and the Knockout Mapping plugin.

  • My MVC3 Action returns a View and not JSON directly as such I convert my Model into JSON.
  • This is a d
相关标签:
2条回答
  • 2021-01-31 23:42

    I guess Response is reserved, when I change "Response" to "resp", everything went fine. See http://jsfiddle.net/BBzVm/

    0 讨论(0)
  • 2021-01-31 23:44

    Should't you use ko.mapping.updateFromJSON on your success event? Chapter Working with JSON strings on Knockout Mapping site says:

    If your Ajax call returns a JSON string (and does not deserialize it into a JavaScript object), then you can use the functions ko.mapping.fromJSON and ko.mapping.updateFromJSON to create and update your view model instead.

    0 讨论(0)
提交回复
热议问题