Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

AJAX interview questions


May 08, 2021 AJAX


Table of contents


AJAX interview questions


Common AJAX interview questions and answers are listed below.

1. What is AJAX?

AJAX stands for Asynchronous JavaScript and XML. I t is a set of related techniques for displaying data asynchronously. In other words, it sends and retrieves data without reloading the page.

2. What are the advantages of AJAX?

  • Quick reply
  • Bandwidth utilization
  • Users are not blocked until data is retrieved from the server.
  • It allows us to send only important data to the server.
  • It makes applications interactive and faster.

3. What are the disadvantages of AJAX?

  • Depends on JavaScript
  • Security issues
  • Debugging is difficult

4, native js ajax request how many steps? What's the difference?

//创建 XMLHttpRequest 对象
var ajax = new XMLHttpRequest();
//规定请求的类型、URL 以及是否异步处理请求。
ajax.open('GET',url,true);
//发送信息至服务器时内容编码类型
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
//发送请求
ajax.send(null);  
//接受服务器响应数据
ajax.onreadystatechange = function () {
    if (obj.readyState == 4 && (obj.status == 200 || obj.status == 304)) { 
    }
};

5, ajax how to request? Their strengths and weaknesses?

Common post, get, delete. C opy, head, link, etc. are not commonly used.

Difference:

(1) Post is safer than get (because the post parameter is in the request body). get parameter above url)

(2) Get transmission speed is faster than post, according to the transfer. ( Post is received by requesting body ginseng, and in the background through the data stream.) I t's a little slower. And get is directly available via url ginseng)

(3) post transfer file big theory does not limit get transfer file small about 7-8k ie4k

(4) get to get data post upload data (upload more data and upload data are important data.) So both security and data magnitude post are the best options)

6. What is the real Web application of AJAX currently running on the market?

  • Twitter
  • Facebook
  • Gmail
  • Javatpoint
  • Youtube

7. What are the security issues with AJAX?

  • The AJAX source code is readable
  • An attacker could insert a script into the system

8. What is the difference between synchronization and asynchronous requests?

Synchronization requests block users until a response is retrieved, and asynchronous does not block users.

9. What technologies does AJAX use?

  • HTML / XHTML and CSS - These techniques are used to display content and styles.
  • DOM - for dynamic display and interaction with data.
  • XML - Used to transfer data between servers
  • XMLHttpRequest - used for asynchronous communication between the client and the server.
  • JavaScript - Is primarily used for client authentication.

10. What is the purpose of XMLHttpRequest?

  • It sends background data to the server.
  • It requests data from the server.
  • It receives data from the server.
  • It updates the data without reloading the page.

11. What are the properties of XMLHttpRequest?

The important properties of the XMLHttpRequest object are given below.

  • onReadyStateChange - Whenever the Readystate property changes, it is called.
  • readyState the status of the request.
  • responseText - It returns the response as text.
  • responseXML - It returns a response in XML format.
  • status - Returns the requested status number.
  • statusText - Returns status details.

12. What is the important method of XMLHttpRequest?

  • abort() - used to cancel the current request.
  • getAllResponseHeaders() Return title details.
  • getResponseHeader() Return specific title details.
  • open() - used to open the request.
  • send() - used to send a request.
  • setRequestHeader() - It adds a request header.

13. What types of open() methods are used by XMLHttpRequest?

  • open(method,URL) - It opens a request that specifies a get or post method and URL.
  • open(method,URL,async) - it is the same as above but specifies asynchronous or not specified.
  • open(method,URL,async,userName,password) - the same as above, but specifying a user name and password.

14, XMLHttpRequest uses some of the types of ending() methods?

  • send() - It sends a get request
  • send(string) - Send a post request.

15. What is the role of callback functions in AJAX?

The callback function passes the function as an argument to another function. If we have to perform various AJAX tasks on the web site, then we can create a function for performing XMLHttpRequest and a callback function for each AJAX task.

16, what is JSON in AJAX?

JSON stands for JavaScript Object Notation. I n AJAX, it is used to exchange data between browsers and servers. I t's easy to understand that data is exchanged faster than XML. It supports arrays, objects, strings, numbers, and values.

request.onreadystatechange   =  function (){    
      if(request.readyState  == 4)    
      {    
        var  jsonObj  =  JSON .parse(request.responseText); // JSON.parse()返回JSON对象    document.getElementById( “日期”).innerHTML  =   jsonObj .date;    
        的document.getElementById( “时间”).innerHTML  =  jsonObj 。时间;    
      }    
   } 

17. What are the tools for debugging AJAX applications?

There are several tools for debugging AJAX applications.

  • Firebug for Mozilla Firefox
  • Fiddler for IE (Internet Explorer)
  • JavaScript HTML debugger
  • MyEclipse AJAX tool
  • Script debugger

18. What are the postback types in AJAX?

There are two types of postbacks in AJAX.

  • Synchronized postback - It blocks the client until the operation is complete.
  • Asynchronous postback - It does not block clients.

19. What are the readiness states for requests in AJAX?

There are 5 requested readiness states in AJAX.

  • 0: Means undetected
  • 1: Indicates that it is open
  • 2: Indicates HEADERS_RECEIVED
  • 3: Indicates loading
  • 4: Indicates completion

20. What is the common AJAX framework?

  • Dojo Toolkit
  • YUI
  • Google Web Toolkit(GWT)
  • Spry
  • MooTools
  • Prototype

21. How do you test the AJAX code?

JUnit is the open source unit testing framework for client JavaScript. A test case needs to be created. A unit test case is a code that ensures that program logic works as expected.

22. What's the difference between JavaScript and AJAX?

Javascript Ajax
JavaScript is an object-based scripting language. AJAX is a set of interrelated technologies such as JavaScript, XML, HTML, CSS, and so on
It requests the server and waits for a response. It sends a request to the server without waiting for a response.
Reloading the page takes up more bandwidth. It does not reload the page and therefore consumes less bandwidth.