Sending the order to the server
Once you can communicate with the server to manage our products, it's time to send the order. For this purpose, follow these instructions:
Create a file named
resources/OrderResource.js
with this content:'use strict'; var OrderResource = (function () { function create(order) { return $.ajax({ type: 'PUT', url: '/order', data: order }); } return { create: create }; })();
Mock the call by creating a file called
mocks/order.js
and adding this code:$.mockjax({ type: 'POST', url: '/order', status: 200, responseTime: 750, responseText: { 'data': { text: 'Order created' } } });
Update the
finishOrder
method in theviewmodel.js
file:var finishOrder = function() { OrderResource.create().done(function(response){ cart([]); visibleCart(false); showCatalog(); $('#finishOrderModal').modal('show'); }); };
One of the requirements of our application is that the user has the option to update personal...