How much do you do with Ajax common interview questions? 12 common facets of Ajax questions and their answers

Source: Internet
Author: User
Tags script tag sql injection browser cache

This article focuses on the question of Ajax questions and answers, you can take a look at the interview of those who are how to issue, and see what the correct answer is. Now, let's see this article.

1. Do you interact with the background during work? Well, can you tell me a few parameters in the encapsulated Ajax?

URL: The address where the request was sent.

Type: The request method (post or get) defaults to get.

Async: Synchronous asynchronous request, default True all requests are asynchronous requests.

Timeout: Time-out setting, per millisecond

Data: A parameter that is required to be an object or string that is sent to the server

Cache: The default is True (default to False when datatype is script), and set to false will not load request information from the browser cache.

DataType: Expected data type returned by the server.

The following types are available:

XML: Returns an XML document that can be processed with jquery.

HTML: Returns plain text HTML information, and the included script tag is executed when the DOM is inserted.

Script: Returns plain text JavaScript code. Results are not automatically cached.

JSON: Returns the JSON data.

JSONP:JSONP format. When a function is called using the Jsonp form, for example Myurl?callback=?,jquery will automatically replace the latter "?" is the correct function name to execute the callback function.

Text: Returns a plain text string.

Success: callback function called after successful request, there are two parameters.

(1) The data returned by the server and processed according to the datatype parameter.

(2) A string describing the status.

Error: A function that requires a parameter of type function, which is called when the request fails. The function has 3 parameters

(1) XMLHttpRequest Object

(2) Error message

(3) Captured Error object (optional)

Complete:function (xmlhttprequest,status) {//Final execution parameters after request completion

2.json data if you're dealing with his format, do you have a fixed format in your previous work? If I send a request to delete a piece of data in the data how do I know if the deletion was successful or where it will be displayed after deletion

Json.parse () is converted to a JSON object, parsed according to the data, and placed on the page.

Format: {} combined with [] JSON string concatenation

Sends a request to delete the data, the background returns the result of the processing, the foreground determines whether the result is successful, and then processes the page element.

3. Have you ever encountered this situation in IE browser background picture data has changed but the client has not changed how to deal with it? He hints that the browser's cache

The Jquery.ajax () method, which sets the cache to False, does not load the request from the browser cache.

Or use the Post method, request data, not cache, each time is to re-request the data

4. How to Implement the tab

Mouse Hover time, call method, pass in this, on all tab contents Part hide operation, display operation for this, control display

5. The implementation of the cascade of ideas

The general area data is the use of two-dimensional array storage, from the background to be stored later.

Based on the option of the first drop-down box, find the corresponding two-dimensional array data, loop new Option () add into the drop-down box

6. Implementation of the Carousel diagram

The first type:

Take the name of the picture in order, use the timer, how many seconds each, change the path of the picture

The second type:

The use of seamless scrolling technology, the picture is placed in the page, the timer to scroll scrolling, to determine the scrolling distance to take the remainder (%) The width of the picture is equal to 0, pause the timer, and then turn on the timer after a few seconds.

7. Tell me about the bootstrap you understand.

Bootstrap is based on HTML5 and CSS3 development, it on the basis of jquery has been more personalized and humanized perfection, only need to give the label to respond to the class name, you can form a set of bootstrap own unique website style, and compatible with most jquery plugins.

The difference between 8.angularjs and JQ

JQ is first acquired for re-use.

Angularjs Direct Use

The difference between 9.JQmobile and JQ

JQuery Mobile is the framework for creating mobile Web applications. JQuery Mobile is suitable for all popular smartphones and tablets. JQuery Mobile uses HTML5 and CSS3 to lay out pages with as few scripts as possible

(1) jquery is a JS library, the main features are selectors, property modification and event binding and so on.
(2) jquery UI is based on jquery, using the extensibility of jquery, the design of plug-ins. Some common interface elements are provided, such as dialog box, drag behavior, change size behavior, and so on.
(3) jquery itself is focused on the background, there is no beautiful interface, and the jquery UI complements the former shortcomings, he provides a gorgeous display interface, making it easier to accept. There are both powerful backstage and gorgeous front desk. The jquery UI is a jquery plugin that only refers to plugins that are officially maintained by jquery in the direction of the UI.

Four parts of 10.ajax:

var xmlhttp = new XMLHttpRequest (); Xmlhttp.open ("post| | Get "," URL ", true| | FALSE); Xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded"); Xmlhttp.onreadystatechange = Callback;xmlhttp.send (null);

What is the data type that 11.ajax receives?

String

JSON string

JSON object

12. Where Ajax is needed, what is not, what are the advantages of Ajax, and what are the drawbacks?

When the page does not jump refresh, when processing data asynchronously, the form auto-complete function----use AJAX,

After submission no longer use the original page, you can jump to refresh, query and other functions, can not Ajax

Advantages:

<1>: No refresh update data.
The biggest advantage of Ajax is the ability to communicate with the server to maintain data without refreshing the entire page. This enables the Web application to respond more quickly to user interactions and avoids sending information that is not changed on the network, reducing user latency and bringing a very good user experience.
<2>. Asynchronously communicates with the server.
Ajax uses asynchronous methods to communicate with the server, without interrupting the user's operations and having more rapid responsiveness. Optimize communication between browser and server, reduce unnecessary data transfer, time and reduce traffic on network.
<3>: Front-end and back-end load balancing.
Ajax can pass on some of the previous server workloads to the client, take advantage of the client's idle ability to handle, reduce server and bandwidth burden, save space and broadband rental costs. and reduce the burden of the server, the principle of Ajax is "on-demand data", can minimize the redundancy request and response to the burden on the server, improve site performance.
<4> standards-based is widely supported.
Ajax is based on standardized and widely supported technologies that do not require a browser plugin or applet to be downloaded, but require the client to allow JavaScript to be executed on the browser. With the maturation of Ajax, a number of libraries that simplify the use of Ajax have been introduced. Similarly, there is another assistive programming technique that provides alternative functionality for users who do not support JavaScript.
<5>: interface and application separation.
Ajax separates the interface in the Web from the application (or the separation of data and rendering), facilitates division of labor, reduces web application errors caused by non-technical changes to the page, improves efficiency, and is more applicable to today's publishing systems.

Disadvantages:

<1>. Ajax kills back and the history function, which is the destruction of the browser mechanism.
in the case of dynamically updating the page, the user cannot go back to the previous page state because the browser can only remember the static pages in the history. The difference between a fully read page and a page that has been dynamically modified is very subtle; The user will typically want to click the Back button to cancel their previous operation, but in an AJAX application this will not be possible.
The Back button is an important feature of a standard web site, but it does not work well with JS. This is a serious problem with Ajax, because users often want to be able to undo the previous operation by going backwards. So is there any way to do this question? The answer is yes, using Gmail know, Gmail under the Ajax technology to solve the problem, in Gmail can be back, but it does not change the mechanism of Ajax, it is only a relatively stupid but effective way, that is, the user click the Back button to access the history To reproduce the changes on the page by creating or using a hidden iframe. (for example, when a user clicks back in Google Maps, it searches in a hidden iframe and then reflects the search results on an AJAX element to restore the application state to its current state.) )
However, while this problem can be solved, the cost of development is very high and deviates from the rapid development required by the AJAX framework. This is a very serious problem caused by Ajax.
A related view is that using dynamic page updates makes it difficult for users to save a particular state to a collection. The solution for this problem has also occurred, with most of the URL fragment identifiers (often referred to as anchors, which are the parts of the # URL) to keep track of, allowing the user to return to the specified application state. (many browsers allow JavaScript to dynamically update the anchor point, which allows an AJAX application to update the anchor point while updating the display.) These solutions also address many of the arguments that do not support back buttons. (Want to see more on the Topic.alibabacloud.comAJAX Development Manual section of the study)

<2>. Security issues with Ajax.
Ajax technology provides users with a good user experience, but also brings new security threats to it enterprises, Ajax technology is like the enterprise data set up a direct channel. This allows developers to inadvertently expose more data and server logic than ever before. The logic of Ajax can be hidden from the client's security scanning technology, allowing hackers to create new attacks from remote servers. And Ajax also makes it difficult to avoid some known security weaknesses, such as cross-site footstep attacks, SQL injection attacks, and credentials-based security vulnerabilities.
<3> Support for search engines is weak.
support for search engines is weaker. If used improperly, Ajax can increase the flow of network data, thereby reducing the overall system performance.
<4>: The exception handling mechanism of the sabotage program.
at least for now, these Ajax frameworks, like Ajax.dll,ajaxpro.dll, can disrupt the program's exception mechanism. On this issue, had encountered in the development process, but looked at the internet there is little relevant introduction. Later, an experiment was done to delete a piece of data using Ajax and the traditional form submission mode ... It has brought us a lot of difficulties in debugging.
<5>: Violates the original intention of URL and resource location.
For example, I give you a URL address, if you use Ajax technology, perhaps you see below the URL address and what I see under this URL is different. This is contrary to the original intention of resource positioning.
<6>. Ajax does not support mobile devices very well.
some handheld devices (such as mobile phones, PDAs, etc.) are not yet well-supported Ajax, for example, when we open a website with Ajax technology on a mobile phone's browser, it is currently unsupported.
<7> client-side fat, too many client-side code causes development costs.
write complex, error-prone, redundant code is more (layer contains JS file is the common problem of Ajax, coupled with many of the previous service-side code is now placed on the client), destroying the original standards of the Web.

This is the end of this article (want to see more on the Topic.alibabacloud.comAJAX User manual section of the study), there are questions can be in the message below the question.

Related Article

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.