Sending Data to the Server
The first method you will create is the add method to store customer order data on the remote web service.
Add a prototype method to RemoteDataStore. Like
DataStore’s add method, it
will accept arguments called key
and
val
. Note that it is not required for you to use
the same parameter names, but it is good practice to keep them
consistent.
... function RemoteDataStore(url) { ... } RemoteDataStore.prototype.add = function (key, val) { // Code will go here }; App.RemoteDataStore = RemoteDataStore; window.App = App; ...
Using jQuery’s $.post method
Inside the RemoteDataStore module, you will use jQuery’s
$.post method. This method sends a POST
request in the background as an XMLHttpRequest
object ...
Get Front-End Web Development: The Big Nerd Ranch Guide 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.