Sending parameters to the server

One of the common tasks in the development of responsive applications is the AJAX execution of a controller method. Sometimes, we need to execute the method with some parameters (or method arguments). Let's consider a simplified version of the library example; we will keep only the number of books. In the following example, the business model needs three methods: the addition of one book, the addition of two books, and the addition of three books. Of course, we can implement three different methods for these tasks. However, a single method with an argument is a more flexible approach.

The Model will be as follows:

public class LibraryModel { public int AmountOfBooks { get; set; } public void AddBooks(int count) { ...

Get Getting Started with Knockout.js for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.