Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook
Lesson 1: Getting started with Node.js CHAPTER 8 359 The response has a writeHead method to write headers. There is also a write ...
360 CHAPTER 8 Websites and services Did you notice that the URL to get the HelloForm.html page was the following? http://localho ...
Lesson 1: Getting started with Node.js CHAPTER 8 361 In the command prompt window, execute the following npm command to retrieve ...
362 CHAPTER 8 Websites and services if (request.method.toLowerCase() == 'post') { // parse form data var form = new formidable.I ...
Lesson 1: Getting started with Node.js CHAPTER 8 363 Quick check ■■What does the following command accomplish? npm install Quick ...
364 CHAPTER 8 Websites and services Lesson 2: Working with web services In the previous lesson, you saw how you can create a web ...
Lesson 2: Working with web services CHAPTER 8 365 Understanding Representational State Transfer (REST) REST attempts to use the ...
366 CHAPTER 8 Websites and services You can implement security by using HTTPS protocol to encrypt the communications and basic a ...
Lesson 2: Working with web services CHAPTER 8 367 In this example, a math_service folder is created under the node_samples folde ...
368 CHAPTER 8 Websites and services The addition operation uses the GET method as signified by the app.get function call. This c ...
Lesson 2: Working with web services CHAPTER 8 369 </head> <body> <form id="mathForm"> Enter X:<input type=" ...
370 CHAPTER 8 Websites and services In the math web service, the result is not XML; it’s JSON, so the last line of code needs to ...
Lesson 2: Working with web services CHAPTER 8 371 Now that the code is operational, you might want to execute the AJAX call asyn ...
372 CHAPTER 8 Websites and services if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var jsonObject = JSON.parse( ...
Lesson 2: Working with web services CHAPTER 8 373 Now that you know about the XMLHttpRequest object, be aware that browsers migh ...
374 CHAPTER 8 Websites and services ■■.serialize() Helper method to encode a set of form elements as a string for submission ■■. ...
Lesson 2: Working with web services CHAPTER 8 375 You can use a more concise way to write this code with the $.get() method inst ...
376 CHAPTER 8 Websites and services var y = $('#y').val(); var data = { "x": x, "y": y }; $.post('/subtraction', data, function ...
Lesson 2: Working with web services CHAPTER 8 377 response.end('{ "result": ' + result + '}'); console.log('Handled addition req ...
378 CHAPTER 8 Websites and services When you use jQuery to execute an AJAX call, a promise object is returned. Think of a promis ...
«
15
16
17
18
19
20
21
22
23
24
»
Free download pdf