Home Web Front-end JS Tutorial 20 classic AJAX interview questions

20 classic AJAX interview questions

Dec 30, 2017 pm 04:34 PM
ajax classic test questions

This article introduces you to 20 jquery ajax interview questions, which are often asked during the front-end development stage. Today, I will share with you 20 classic AJAX interview questions. ajaxInterested friends, let’s study together

[Related recommendations: front-end interview questions (2020), ajax interview questions(2020)]

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

What is ajax :

AJAX is the abbreviation of "Asynchronous JavaScript and XML". It refers to a web development technology for creating interactive web applications.

Ajax includes the following technologies:

Based on web standards (standards-basedpresentation) XHTML+CSS presentation;

Using 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. Pass Asynchronous mode improves user experience

2. Optimizes the transmission between the browser and the server, reduces unnecessary data round-trips, and reduces bandwidth usage

3 . The Ajax engine runs on the client and takes on part of the work originally performed by the server, thus reducing the server load under large user volumes.

2. What is the biggest feature of AJAX.

Ajax can achieve dynamic non-refresh (partial refresh)

It means that data can be maintained 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 and is a technology that supports asynchronous requests. In short, XmlHttpRequest allows you to use JavaScript to make requests to the server and handle the responses without blocking the user. Through the XMLHttpRequest object, web developers can perform partial updates to the page after the page is loaded.

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

##HTML, css, dom, xml, xmlHttpRequest, javascript


##5. AJAX applications and traditional Web applications are What a difference.
In traditional Javascript programming, if you want to get information from a server-side database or file, or send client 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 to reload.


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


Using AJAX technology, Javascript can interact directly 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). The user is still shown the same page, and the user feels that the page is refreshed. , and you can't see the Javascript sending requests and receiving responses in the background.


#6. How many types of CALLBACK are there in AJAX requests?
Ajax request has a total of eight types of Callback

1

2

3

4

5

6

7

8

onSuccess

onFailure

onUninitialized

onLoading

onLoaded

onInteractive

onComplete

onException

Copy after login

7. The difference between Ajax and javascript. Javascript is a scripting language that is executed on the browser side. Ajax is a development technology for creating interactive web applications. It uses 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. 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


Through XML data or strings


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 how the XMLHttpRequest object is created in IE and Firefox. Yes, it can be obtained through new ActiveXObject() in IE and through newXMLHttpRequest() in Firefox

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

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

The second parameter is the URL of the requested page.

send() method, send a specific request

abort() method, stop the current request

readyState attribute request status is 5 Available values ​​are 0=not initialized, 1=loading
2=to load, 3=interacting, 4=complete

responseText attribute The response of the server, represented as a string

reponseXML attribute server's response, expressed as XML

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

12. What is XML

XML is an extended markup language that can describe data using a series of simple tags

##13. XML parsing methods

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


14. What framework (package) are you using?

This question is a must-ask, 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 some kind of ajax framework , he may ask how to use this framework in the program

DWR framework introduction

DWR (DirectWeb Remoting) is A WEB remote calling framework. Using this framework can make AJAX development very simple. Using DWR, you can use JavaScript on the client to directly call the server's Java method and return the value to JavaScript, just like direct local client calls (DWR is based on the Java class to dynamically generate JavaScript code).


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 what the $() function, $F() function, and $A() function of Prototype do.

$() method is A convenient shorthand for the all-too-frequently used document.getElementById() method in the DOM. Like this DOM method, this method returns the element with the id passed in as the parameter.


$F() function is another popular "shortcut key". It 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.


$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 to 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 method. language, but it is a new programming technology that uses 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?

The definition of Ajax (Asynchronous JavaScript + XML)


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


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


Use XML and XSLT for data exchange and related operations;


Use XMLHttpRequest performs asynchronous data query and retrieval;

Use JavaScript to bind everything together. In English, please see the original text by Jesse James Garrett, the proposer of Ajax, and 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 "derivative/composite" technologies based on AJAX 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 does not 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 asynchronous mode to communicate with the server, with faster response capability.

3. Some of the work previously burdened by the server can be transferred to the client, using the idle capacity of the client to process it, reducing the burden on the server and bandwidth, and saving space and broadband rental costs. And to reduce the burden on the server, the principle of ajax is to "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 technology, there is no need to download plug-ins or small programs.

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. Destroyed the exception mechanism of the program.

5. Not easy to debug.

The above are 20 classic AJAX interview questions introduced by the editor. I hope it will be helpful to everyone!

Related recommendations:

Detailed explanation of the interaction between front-end ajax and back-end

Detailed explanation of examples to quickly obtain Ajax communication objects

Example detailed explanation js combined with json to implement ajax simple example

The above is the detailed content of 20 classic AJAX interview questions. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1253
29
C# Tutorial
1227
24
PHP and Ajax: Building an autocomplete suggestion engine PHP and Ajax: Building an autocomplete suggestion engine Jun 02, 2024 pm 08:39 PM

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.

How to solve the 403 error encountered by jQuery AJAX request How to solve the 403 error encountered by jQuery AJAX request Feb 20, 2024 am 10:07 AM

Title: Methods and code examples to resolve 403 errors in jQuery AJAX requests. The 403 error refers to a request that the server prohibits access to a resource. This error usually occurs because the request lacks permissions or is rejected by the server. When making jQueryAJAX requests, you sometimes encounter this situation. This article will introduce how to solve this problem and provide code examples. Solution: Check permissions: First ensure that the requested URL address is correct and verify that you have sufficient permissions to access the resource.

How to solve jQuery AJAX request 403 error How to solve jQuery AJAX request 403 error Feb 19, 2024 pm 05:55 PM

jQuery is a popular JavaScript library used to simplify client-side development. AJAX is a technology that sends asynchronous requests and interacts with the server without reloading the entire web page. However, when using jQuery to make AJAX requests, you sometimes encounter 403 errors. 403 errors are usually server-denied access errors, possibly due to security policy or permission issues. In this article, we will discuss how to resolve jQueryAJAX request encountering 403 error

How to solve the problem of jQuery AJAX error 403? How to solve the problem of jQuery AJAX error 403? Feb 23, 2024 pm 04:27 PM

How to solve the problem of jQueryAJAX error 403? When developing web applications, jQuery is often used to send asynchronous requests. However, sometimes you may encounter error code 403 when using jQueryAJAX, indicating that access is forbidden by the server. This is usually caused by server-side security settings, but there are ways to work around it. This article will introduce how to solve the problem of jQueryAJAX error 403 and provide specific code examples. 1. to make

How to get variables from PHP method using Ajax? How to get variables from PHP method using Ajax? Mar 09, 2024 pm 05:36 PM

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

PHP vs. Ajax: Solutions for creating dynamically loaded content PHP vs. Ajax: Solutions for creating dynamically loaded content Jun 06, 2024 pm 01:12 PM

Ajax (Asynchronous JavaScript and XML) allows adding dynamic content without reloading the page. Using PHP and Ajax, you can dynamically load a product list: HTML creates a page with a container element, and the Ajax request adds the data to that element after loading it. JavaScript uses Ajax to send a request to the server through XMLHttpRequest to obtain product data in JSON format from the server. PHP uses MySQL to query product data from the database and encode it into JSON format. JavaScript parses the JSON data and displays it in the page container. Clicking the button triggers an Ajax request to load the product list.

PHP and Ajax: Ways to Improve Ajax Security PHP and Ajax: Ways to Improve Ajax Security Jun 01, 2024 am 09:34 AM

In order to improve Ajax security, there are several methods: CSRF protection: generate a token and send it to the client, add it to the server side in the request for verification. XSS protection: Use htmlspecialchars() to filter input to prevent malicious script injection. Content-Security-Policy header: Restrict the loading of malicious resources and specify the sources from which scripts and style sheets are allowed to be loaded. Validate server-side input: Validate input received from Ajax requests to prevent attackers from exploiting input vulnerabilities. Use secure Ajax libraries: Take advantage of automatic CSRF protection modules provided by libraries such as jQuery.

What are the ajax versions? What are the ajax versions? Nov 22, 2023 pm 02:00 PM

Ajax is not a specific version, but a technology that uses a collection of technologies to asynchronously load and update web page content. Ajax does not have a specific version number, but there are some variations or extensions of ajax: 1. jQuery AJAX; 2. Axios; 3. Fetch API; 4. JSONP; 5. XMLHttpRequest Level 2; 6. WebSockets; 7. Server-Sent Events; 8, GraphQL, etc.

See all articles