20 classic AJAX interview questions (must know)

1. What is AJAX and why use Ajax (please talk about your understanding of Ajax)

What is ajax:

AJAX is an acronym for "Asynchronous JavaScript and XML". It refers to a web development technique for creating interactive web applications.

Ajax includes the following technologies:

Representation based on web standards (standards-basedpresentation) XHTML+CSS;

Use DOM (Document ObjectModel) for dynamic display and interaction;

Use XML and XSLT for data exchange and related operations;

Use XMLHttpRequest for asynchronous data query and retrieval;

Use JavaScript to tie everything together.

2. Why use ajax:

The advantages of Ajax applications are:

1. Through the asynchronous mode, the user experience is improved

2. Optimize the transmission between the browser and the server, reduce unnecessary data round-trips, and reduce bandwidth occupation

3. The Ajax engine runs on the client side and undertakes part of the work originally undertaken by the server, thereby reducing the server load under a large number of users.

2. What is the biggest feature of AJAX.

Ajax can achieve dynamic non-refresh (partial refresh)

It is the ability to maintain data without updating the entire page. This allows web applications to respond more quickly to user actions and avoids sending unchanged information over the network.

3. Please introduce the XMLhttprequest object.

The core of Ajax is the JavaScript object XmlHttpRequest. This object was first introduced in Internet Explorer 5 as a technology to support asynchronous requests. In a nutshell, XmlHttpRequest lets you use JavaScript to make requests to a server and process responses without blocking the user. Through the XMLHttpRequest object, Web developers can perform partial updates of the page after the page is loaded.

4. What are the components of the AJAX technology system?

HTML,css,dom,xml,xmlHttpRequest,javascript

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

In traditional Javascript programming, if you want to get information on the server-side database or file, or send client-side information to the server, you need to create an HTML form and then GET or POST data to the server. Users need to click the "Submit" button to send or receive data information, and then wait for the server to respond to the request, and the page is reloaded.

Because the server returns a new page every time, traditional web applications can be slow and user-unfriendly.

Using AJAX technology, Javascript can directly interact with the server through the XMLHttpRequest object.

Through 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). What is displayed to the user is still a page. The user feels that the page is refreshed, and cannot see the Javascript background. Send requests and receive responses.

6. How many CALLBACKs are there in total for AJAX requests?

Ajax requests have a total of eight Callbacks

onSuccess
onFailure
onUninitialized
onLoading
onLoaded
onInteractive
onComplete
onException

7. The difference between Ajax and javascript.

JavaScript is a scripting language executed on the browser side, and Ajax is a development technology for creating interactive web applications, which utilizes a series of related technologies including JavaScript.

Javascript is a scripting language developed by Netscape. It has nothing to do with Sun's Java language. Their similar names are just a marketing strategy.

In general web development, javascript is executed on the browser side, and we can use javascript to control the behavior and content of the browser.

How information is passed between the browser and the server in an Ajax application

via XML data or string

8. How to get the XML data responded by the server on the browser side.

The responseXMl attribute of the XMLHttpRequest object

9. Is there any difference in the way XMLHttpRequest objects are created in IE and Firefox?

Yes, obtained through new ActiveXObject() in IE, and obtained through newXMLHttpRequest() in Firefox

10. Introduce the common methods and attributes of the XMLHttpRequest object.

open("method","URL") establishes a call to the server, the first parameter is the HTTP request method can be GET, POST or any method you want to call supported by the server.

The second parameter is the URL of the requested page.

send() method, send a specific request

abort() method, stop the current request

The status of the readyState attribute request has 5 possible values ​​0 = not initialized, 1 = loading
2 = to load, 3 = interacting, 4 = completed

responseText attribute The server's response, expressed as a string

responseXML attributes the server's response, expressed as XML

status The HTTP status code of the server, 200 corresponds to ok and 400 corresponds to not found

12. What is XML?

XML is an Extensible Markup Language that can describe data with a series of simple tags

13. XML parsing method

Commonly used dom analysis and sax analysis. dom parsing is to read the xml file at one time and construct it into a DOM object for the program to use. The advantage is that it is easy to operate, but it consumes more memory. Sax is parsed in an event-driven manner, takes up less memory, but is complex to program

14. What frame do you use (frame package)

This question is a must, and is usually asked at the very beginning.

The more popular ones in java are dojo, Prototype, JQuery, Dwr, extjs, etc.

15. If you are familiar with a certain ajax framework, he may ask how to use this framework in the program

DWR framework introduction

DWR (DirectWeb Remoting) is a WEB remote call framework. Using this framework can make AJAX development very simple. Using DWR, you can use JavaScript on the client side to directly call the Java method on the server side and return the value to JavaScript just like a direct local client call. Same (DWR dynamically generates JavaScript code based on Java classes).

The implementation principle of DWR is to translate java into javascript through reflection, and then use the callback mechanism to realize javascript calling Java code

16. Introduce the $() function, $F() function and $A() function of Prototype.

The $() method is a convenient shorthand for the overused document.getElementById() method in the DOM. Like this DOM method, this method returns the element with the id passed in as a parameter.

The $F() function is another popular "shortcut key", which can be used to return the value of any form input control, such as textbox, drop-down list. This method can also take an element id or the element itself as a parameter.

The $A() function can convert the single parameter it receives into an Array object.

17. Introduce the XMLHttpRequest object

Through the XMLHttpRequest object, Web developers can perform partial updates of the page after the page is loaded.

AJAX became popular when Google used "Google Suggest" in 2005.

"Google Suggest" uses the XMLHttpRequest object to create a dynamic web interface:

When the user starts typing in google's search box, Javascript sends the characters entered by the user to the server, and the server returns a list of suggestions.

The XMLHttpRequest object is supported in IE5.0+, Safari 1.2, Mozilla1.0/Firefox, Opera 8+ and NetScapt7.

18. What is the full name of AJAX? Introduce AJAX?

The full name of AJAX is Asynchronous JavaScript And XML.

AJAX is a programming method initiated by Google in 2005 and became popular. AJAX is not a new programming language, but it is a new programming technology using existing standards.

Use AJAX to create better, faster, and more user-friendly web applications.

AJAX technology is based on Javascript and HTTP Request.

19. What technologies does Ajax mainly include?

Definition of Ajax (Asynchronous JavaScript + XML)

Representation based on web standards (standards-based presentation) XHTML+CSS;

Use DOM (Document Object Model) for dynamic display and interaction;

Use XML and XSLT for data exchange and related operations;

Use XMLHttpRequest for asynchronous data query, retrieval;
use JavaScript to tie everything together. For English, see the original text of the author of Ajax, Jesse James Garrett, the original title (Ajax: A New Approach to

Web Applications)。

Similar to DHTML or LAMP, AJAX does not refer to a single technology, but organically utilizes a series of related technologies. In fact, some AJAX-based "derivative/composite" (derivative/composite) technologies are emerging, such as "AFLAX".

AJAX applications use web browsers that support the above technologies as the running platform. These browsers currently include: Mozilla, Firefox, Internet Explorer, Opera, Konqueror, and Safari. But Opera doesn't support XSL format objects, nor does it support XSLT.

20. What are the advantages and disadvantages of AJAX?

1. The biggest point is that the page does not refresh, and the user experience is very good.

2. Use the asynchronous method to communicate with the server, which has a more rapid response capability.

3. It is possible to transfer some of the work borne by the server to the client, and use the idle capacity of the client to handle it, reduce the burden on the server and bandwidth, and save space and broadband rental costs. And to reduce the burden on the server, the principle of ajax is "fetch data on demand", which can minimize the burden on the server caused by redundant requests and responses.

4. Based on standardized and widely supported technologies, there is no need to download plug-ins or applets.

Disadvantages of ajax

1. Ajax does not support the browser back button.

2. Security issues AJAX exposes the details of interaction with the server.

3. The support for search engines is relatively weak.

4. The abnormal mechanism of the program is destroyed.

5. It is not easy to debug.

Guess you like

Origin blog.csdn.net/m0_63951142/article/details/128841816