HTML5. With jquery and Ajax common face questions

Source: Internet
Author: User
Tags browser cache

1. HTML5


1.1. Brief description of local storage in HTML5

Reference Answer:


Many times we store the user's local information on the computer, for example: The user has a half-filled long
Table, and then suddenly the network connection disconnects, so the user wants you to be able to store this information locally, when the network recovers
He wants to get this information and send it to the server for storage.
Modern browser-owned storage is called "Local Storage" for storing this information.

1.2. Briefly describe the role of canvas in HTML5

Reference Answer:


Canvas is a new label that appears in the HTML5, with its own properties, methods, and events, with the drawing side
J Ava Sc Ri pt is able to invoke it to complete the drawing on a Web page.
Canvas is also one of the most powerful features in HTML5, allowing developers to use dynamic and interactive visualization methods
The ability to implement desktop applications on the Web.

What are the different types of storage for 1.3. HTML5?

Reference Answer:


HTML5 supports local storage, which is implemented in previous versions via cookies. HTML5 Local Storage speed
Fast and secure.
There are two different kinds of objects that you can use to store data:
? Localstorage: For long-term storage of data, the browser is closed after the data is not lost; Sessionstorage: Stored data is automatically deleted when the browser is closed.

1.4. In addition to audio and video, what other new Media Elements does HTML5 support?

Reference Answer:

HTML5 has a strong media support, in addition to audio and video, also provides:
? <embed>: As a container for external applications; <track>: Define text tracking for media;? <SOURCE>: Support for multiple media sources.

1.5. HTM L5 What is the application cache?

Reference Answer:
It is commonly used to implement offline browsing for users. If the network connection is not available, the page should be from the browser cache, and the offline application cache can help you achieve this goal.
Application caching helps you specify which files need to be cached and which do not.

1.6. What is a Web Worker? Why do we need them?

Reference Answer:


Look at the following code (the simulation will execute millions of heavy code):

function Test () {
for (i=0;i< 10000000000; i++) {
X=x+i;
}
}
If the above code is executed after the HTML button is clicked, the execution is synchronous, that is, the browser must wait until the execution is complete before other actions can be performed. Because this operation takes a long time, this action causes the browser to freeze and not respond, and the screen will also receive exception information.
If you can move these heavy code into a JavaScript file and run it asynchronously, you can solve the problem. This is the role of web worker. Web worker is used to execute JavaScript files asynchronously to improve the agility of the browser.

1.7. HTM L5 What is the difference between application cache and browser cache

Reference Answer:
Application caching is one of the most important features of the HTM L5, providing offline usage that allows applications to get local content, such as HTML, CSS, pictures, and Javascript. This feature can improve the performance of the site, its implementation with the help of the manifest file, the code is as follows:

<!doctype html>
Jqu E ry and 3

It does not force user access to site content to be cached compared to traditional browser caches.

1.8. Briefly describe the new form elements in HTML5

Reference Answer:


Datalist,datetime, output, date, Month,week,time,color, number, range,
Email, URL, search and more.

2.jquery


2.1. The onload () function in the body and $ (document) in jquery. What's the difference between ready ()

Reference Answer:


The difference between onload () and Document.ready () is as follows:
? You can use multiple Document.ready () in a page, but only one time, onload (); The Document.ready () function is called after the page DOM element is loaded.
The onload () function is called when all associated resources (including images, audio) are loaded.

2.2. What kinds of selectors are available in Jque ry

Reference Answer:


There are 3 types of selectors, as follows:


Basic selector: Returns DOM element directly based on ID, CSS class name, element name;
Hierarchy selector: Also called the path selector, the corresponding DOM elements can be selected according to the path hierarchy;
Filter selector: Filters the relevant conditions on the previous basis to get a matching DOM element.

What is the effect of the $2.3.jQuery dollar sign?

Reference Answer:


The dollar sign $ is an alias for ' jquery ', which is the jquery selector, which looks like this code:

$ (document). Ready (function () {});

4

You can also use Jque ry to replace

JQuery (document). Ready (function () {});


What is the function of the Delegate () function in 2.4.jQuery?

Reference Answer:


Delegate () will be used in the following two cases:


? When you need to add an event to the child element under the parent element, the code is as follows:

HTML code
$ ("ul"). Delegate ("Li", "click", Function () {$ (this). Hide ();
});

? When the element is not available in the current page, you can use the delegate ()

3. AJAX


3.1. Please write down at least 5 common HTTP status codes and the meaning of the representative

Reference Answer:


The 5 common HTTP status codes and the meanings of the delegates are as follows:


? (OK): The request was successful and the desired response header or data body will be returned with this response.
? 303 (see other): tells the client to use another URL to get the resource.
? (Bad Request): Requested format error. 1) Incorrect semantics, the current request cannot be server
Understand. The client should not submit the request repeatedly unless the modification is made; 2) the request parameter is incorrect. 404 (Not Found): The request failed and the requested resource was not found on the server. (Internal server Error): The server encountered an unexpected condition that caused it
The processing of the request could not be completed.

3.2. Briefly describe your understanding of Ajax

Reference Answer:
The full name of Ajax is "asynchronous JavaScript and XML", which is asynchronous JavaScript and XM L. It refers to a web development technique that creates an interactive Web page application that enables asynchronous requests and local refreshes of the page.

5


Ajax includes the following techniques:


? Representation of web-based standard XHTML+CSS
? Use the DOM (Document ObjectModel) for dynamic display and interaction? Data exchange and related operations using XML and XSLT
? Use XMLHttpRequest for asynchronous data querying, retrieving

3.3. Please introduce the XMLHttpRequest object

Reference Answer:


The core of Ajax is the JavaScript object XMLHttpRequest. The object is in the Internet Explorer5
First introduced, it is a technique that supports asynchronous requests. In short, Xml HttpRequest can use JavaScript
Make a request to the server and process the response without blocking the user. Through XMLHttpRequest objects, web development
People can make local updates to the page after the page is loaded.

3.4. What is the difference between AJAX applications and traditional Web applications

Reference Answer:


In traditional JavaScript programming, if you want information on a server-side database or file, or send
Client information to the server, you need to create an HTM L form and then get or post data to the server side.
Users need to click the "Submit" button to send or receive data information, and then wait for the server to respond to the request, page
Reload. Because the server returns a new page every time, traditional Web applications can be slow and
Poor user interaction.
With Ajax technology, JavaScript can be xmlhttprequest directly to the server via the
Line interaction. With HTTP request, a Web page can send a request to the Web server and accept
The information returned by the Web server (without reloading the page), presented to the user or the same page, but only implemented page
The local refresh of the polygon to improve the degree of experience.

3.5. Describe the common methods and properties of the XM Lhttprequest object

Reference Answer:


? Open ("Method", "URL"): establishes a call to the server, the first parameter is the HTTP
Request method (can be a GET, post or any server supported by the way you want to call),
Two parameters are the URL of the requested page;
? Send () method: sends a specific request;
? Abort () Method: stops the current request;
? ReadyState property: The state of the request, with 5 desirable values (0 = uninitialized, 1 = loading,
},error:function () {window.alert ("system error");} 6
2= to load, 3 = interactive, 4 = complete);
? ResponseText property: The response of the server, expressed as a string;? Reponsexml property: The response of the server, expressed as XML;? Status property: The HTTP status code for the server.

3.6. Describe the interaction model of Ajax and the difference between synchronous and asynchronous

Reference Answer:
Ajax is primarily used to implement fetching data from the server and locally refreshing the page. The interaction model is that Ajax introduces an execution engine on the browser side, which receives the user's request, transmits the data to the server, and presents the results of the server-side return to u se r.
Synchronization: The script pauses and waits for the server to send a reply before continuing.
Async: The script does not stay and handle possible replies.

3.7. It is now necessary to implement AJAX requests using jquery code, with the following details:

Url:carinfo.do of the request
Delivery mode: Post
Send data: Value of text box with ID s1
Return Data: JSON format
Request succeeded: Write return data to text box with ID s2 request failed: Popup text "System error"
Please provide code to implement the above functions.


Reference Answer:

$.ajax ({
URL: "Carinfo." Do ",
Type: "Post",
data:$ ("#s1"). Val (),
DataType: "J Son",
Success:function (ResText) {
$ ("#s2"). Val (ResText);
});


3.8. What are the pros and cons of Ajax?

Reference Answer:
Advantages:


? Page local refresh, improve the user experience degree;
? Communicate with the server asynchronously, with more rapid response capability;
? reduce server burden;
? Based on standardized and widely supported technologies, there is no need to download plugins or small programs.


Disadvantages:


? Browser Back button is not supported;
? Security issues;

HTML5. With jquery and Ajax common face questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.