Chap 5
This chapter seems to focus more on POST by ditching send(null) and sending more data to the server. They're back to working on the Break Neck Pizza site.
First, they update the Break Neck HTML by deleting the method="POST" and action="placeOrder.php" and input type="submit" value="Order Pizza" strings. They also replaced the input type to a button and added the JavaScript function, onClick="submitOrder();". Secondly, they send the order to the server by writing the submitOrder JavaScript function. Third, they update the placeOrder.php file by sending less HTML. Fourth, they are going to write teh callback function to display the delivery estimate to the customer. This is where we see that the DOM is connected to the visuals seen by a customer. After, it's time to test the application.
The book goes into ways of checking for errors, how to use error messages, and error handling in JavaScript. They also describe the differences between Get requests and Post requests.
In Get requests, data is sent in the request URL, while Post requests get sent separate to the request URL. The web servers unencode Post data. Post requests allow you to send more data.
Next, they ask you to test the Post request knowing that it doesn't work. They go through a whole dialog discussing what might be wrong. The solution is that the server needs to know what to expect by setting the context type.
They set the content type in the function submitOrder with the request.setRequestHeader string (p308).
They finally go on about the benefits of using Post versus Get.
First, they update the Break Neck HTML by deleting the method="POST" and action="placeOrder.php" and input type="submit" value="Order Pizza" strings. They also replaced the input type to a button and added the JavaScript function, onClick="submitOrder();". Secondly, they send the order to the server by writing the submitOrder JavaScript function. Third, they update the placeOrder.php file by sending less HTML. Fourth, they are going to write teh callback function to display the delivery estimate to the customer. This is where we see that the DOM is connected to the visuals seen by a customer. After, it's time to test the application.
The book goes into ways of checking for errors, how to use error messages, and error handling in JavaScript. They also describe the differences between Get requests and Post requests.
In Get requests, data is sent in the request URL, while Post requests get sent separate to the request URL. The web servers unencode Post data. Post requests allow you to send more data.
Next, they ask you to test the Post request knowing that it doesn't work. They go through a whole dialog discussing what might be wrong. The solution is that the server needs to know what to expect by setting the context type.
They set the content type in the function submitOrder with the request.setRequestHeader string (p308).
They finally go on about the benefits of using Post versus Get.

0 Comments:
Post a Comment
<< Home