In this chapter, we will discuss how we can consume RESTful Services using various clients to perform CRUD operations.
In this chapter, we will cover the following points:
Before we discuss how we can consume WCF RESTful Services, let's take a quick look at LINQ, because we will be using it for querying data throughout this book.
Asynchronous JavaScript and XML (AJAX) is a technology that is used to build applications with fast and responsive user interfaces. AJAX can be used to reduce web page postbacks significantly, thus yielding better response time. Not only can you use AJAX to reduce page hits, but also to submit portions of your web page to the web server in order to reduce network traffic.
Note that Unobtrusive AJAX is the latest evolution of AJAX. This version of AJAX presents a clean separation of behavior (JavaScript), content (HTML), and presentation (CSS), and can work even when JavaScript is turned off in your browser. Unobtrusive AJAX helps make your web applications work irrespective of whether JavaScript is turned off in your web browser. It works even on a mobile phone, screen reader, or the Web.
The technologies that make up AJAX are as follows:
XMLHttpRequest
object is used for the exchange of data between a server and client. Almost all modern-day browsers have an inbuilt XMLHttpRequest
object.The advantages of using AJAX are:
Cross-Origin Resource Sharing (CORS) is a concept that enables AJAX requests to be posted to a domain that is different from the domain of the client. The modern-day browsers, such as Internet Explorer 8+, Firefox 3.5+, Safari 4+, and Chrome provide support for CORS. You can get to know more about CORS at http://www.bennadel.com/blog/2327-Cross-Origin-Resource-Sharing-CORS-AJAX-Requests-Between-jQuery-And-Node-js.htm.
AJAX is heavily dependent on JavaScript, due to which providing multibrowser support applications that use AJAX is a challenge. Also, usage of AJAX makes your web pages difficult to debug and prone to security threats due to the massive usage of JavaScript.