Web Development with jQuery®

(Elliott) #1

(^218) ❘ CHAPTER 7 AJAX
Figure 7-8 shows Safari’s web inspector, which shows the request data sent along to the server.


FIGURE 7-8


Figure 7-9 shows a closer look at the web inspector’s detailed view of the HTTP request and the
server’s response.

This example shows you that setting up a REST request on the client side is easy, but you need to
have the right server-side confi guration to complete an implementation. Implementing a REST ser-
vice call is as easy as pointing your client-side app to a server confi gured to handle the additional
request methods that REST provides. You need to set up the request to specify the right method,
such as GET, POST, DELETE, or ADD, which is done using jQuery’s type property with the
$.ajax() method. Then if you intend to pass JSON data between the server and client, you also need
to set the contentType, dataType, and data properties. The contentType tells the server what to expect
in the body of the request. The dataType property tells jQuery what type of data to expect in the

http://www.it-ebooks.info

Free download pdf