Book Image

Getting Started with Knockout.js for .NET Developers

By : Andrey Ankshin
Book Image

Getting Started with Knockout.js for .NET Developers

By: Andrey Ankshin

Overview of this book

Table of Contents (14 chapters)
Getting Started with Knockout.js for .NET Developers
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Loading and saving JSON data


In client-server applications, there are two very frequent tasks:

  • Receiving data from the server

  • Sending data to the server

These tasks need some format for data exchange. One of the most popular ways is using the JSON format (http://json.org/).

Generally, you can use any mechanism for data exchange operations, ranging from sending XMLHttpRequest and handling the response in pure JavaScript, to using third-party JS libraries and frameworks. It's very convenient to use the following jQuery's AJAX helper methods:

An example of data exchange is as follows:

// Receiving data from the server
$.getJSON("http://myserver.com", function(data) {
  // Here you can use received data
})

// Send data to the server
$.post("http://myserver.com", data, function(returnedData) {
  // Successful callback
})

// Using...