Programming in HTML5 with Javascript and CSS3 Flashcards
- npm install
- npm install -g
- installs locally
- installs globally
Class : blueprint of an object
Object: instance of a class
jQuery promises
- always( )
- done( )
- fail( )
- progress( )
REST
Representational state transfer
- Post (create)
- Get
- Put (update)
- Delete
AJAX
Asynchronous Javascript and XML
- XSS
- CORS
- Cross-site scripting
- Cross origin resource sharing
- rel
- lang
- relation
- language
- tr
- td
- th
- row
- detail
- header
- var jsonObject = JSON.parse(xmlhttp.response);
- result.innerHTML = jsonObject.result;
- The response string needs to be converted to an object and the JSON.parse method can accomplish the task
- In addition, the URL must be pieced together by taking the values from text boxes to build this QueryString
- var xmlhttp=new XMLHttpRequest();
- xmlhttp.open(“GET”,”/addition?x=5&y=10”,false);
- xmlhttp.send();
- var xmlDoc=xmlhttp.responseXML;
- The first line creates a new XMLHttpRequest object and assigns it to the xmlhttp variable.
- The next line sets up the request to use the GET method with a relative URL of /addition and QueryString of x=5&y=10.
- The last parameter (false) indicates whether the operation is to be performed asynchronously when false means that operation is synchronous.
padding: 5px 15px;
- 5px for the top and the bottom
- 15 px for the right and the left
AJAX codes
- 0 Uninitialized The open method has not been called yet.
- 1 Loading The send method has not been called yet.
- 2 Loaded The send method has been called; headers and status are available.
- 3 Interactive Downloading; the response properties hold the partial data.
- 4 Completed All operations are finished.
Handling errors
- xmlhttp.addEventListener(“error”, failed, false);
- xmlhttp.addEventListener(“abort”, canceled, false);
- function transferFailed(evt) {
- alert(“An error occurred”);
- }
- function canceled(evt) {
- alert(“canceled by the user”);
- }
Progress event
- xmlhttp.addEventListener(“progress”, updateProgress, false);
- function updateProgress(evt) {
- if (evt.lengthComputable) {
- var percentComplete = evt.loaded / evt.total;
- //display percenComplete
- } else {
- // Need total size to compute progress
- }
- }
Promise object
The promise object has the done, fail, always, and progress methods that accept
a function parameter, which enables you to subscribe to state change. The then()
method on the promise object enables you to subscribe to done, fail, and progress
Deferred object
The deferred object is a wrapper for the promise object. The deferred object provides control of the promise object, which is read-only
$.when() method
Use the $.when() method to monitor the completion of many parallel asynchronous
calls. Use the $.when() method with no parameters to create a resolved promise object
A web worker
A web worker provides asynchronous code execution
TCP
Transmission Control Protocol
URL
Uniform Resource Locator
URI
Uniform resource identifier
- ws://
- wss://
- Websocket
- Secure websocket
- http://
- https://
- Hypertext Transfer Protocol
- Secure Hypertext Transfer Protocol
The readyState property contains one of the following values
- CONNECTING = 0 Connection is not yet open
- OPEN = 1 Connection is open and ready to communicate
- CLOSING = 2 Connection is in the process of closing
- CLOSED = 3 Connection is closed or couldn’t be opened