Welcome to weblogs.com.pk Sign in | Join | Help

Ajax WCF and Posting from KnockoutJS + jQuery

A while ago I posted about Ajax enabled WCF Service :: Round tripping; in which I didn’t show how to post from Javascript / Client to WCF that expects an entity for scenarios like new record. This is needed when there's already Ajax Enabled WCF is in place, you are migrating from Silverlight or similar technology  to modern Web etc. Today while cleaning out my older Visual Studio Projects folder; I found that solution so thought to add that and post it here!

The project was using KnockoutJS; for the new record entry, I created a separate viewModel JavaScript object matching the fields as expected on the server and made them observable. Binding it to the fieldset in HTML and submitting the data using jQuery.ajax(), the trick was to wrap the viewModel into another object assigning to same variable name that WCF method expect and then JSONify it!

  • Fiddler is a great to debug such issues

KnocoutJs-WCF

Published Tuesday, October 20, 2015 12:42 AM by khurram
Filed under: ,

Comments

No Comments

New Comments to this post are disabled