Ajax Interview Question and Answers

Q1. What is Ajax?

Ans:  Ajax is abbreviated as Asynchronous JavaScript and XML. It is a new technique used to create better, faster and more interactive web systems or applications. Ajax uses asynchronous data transfer between the Browser and the web server. This technique is used to make the internet faster and user-friendly. It is not a programming language.

Q2. What are Ajax applications?

Ans. Browser-based applications and platform-independent applications are used by Ajax.

Q3. What are the advantages of Ajax?

Ans.  Following are the advantages of Ajax:

  1. Bandwidth utilization – It saves memory when the data is fetched from the same page.
  2. More interactive
  3. Speeder retrieval of data

Q4. What are the Disadvantages of Ajax?

Ans. Following are the disadvantages of Ajax:

  1. a) AJAX is dependent on JavaScript. If there is some JavaScript problem with the browser or in the OS, Ajax will not support
  2. b) Ajax can be problematic in Search engines as it uses JavaScript for most of its parts.
  3. c) Source code written in AJAX is easily human readable.

There will be some security issues in Ajax.

  1. d) Debugging is difficult
  2. e) Increases size of the requests
  3. f) Slow and unreliable network connection.
  4. g) Problem with browser back button when using AJAX enabled pages.

     Q5. What are all the technologies used by Ajax?

Ans. AJAX uses following technologies:

  1. a) JavaScript
  2. b) XMLHttpRequest
  3. c) Document Object Model (DOM)
  4. d) Extensible HTML (XHTML)
  5. e) Cascading Style Sheets (CSS)

 Q6.  What is the difference between AJAX and JavaScript?

Ans. The differences between AJAX and JavaScript are as follows:

AJAX:

  • AJAX sends a request to the server and does not wait for the response. It performs other operations on the page during that time
  • AJAX does not require the page to refresh for downloading the whole page
  • AJAX minimizes the overload on the server since the script needs to request once

JavaScript:

  • JavaScript makes a request to the server and waits for a response
  • JavaScript manages and controls a Web page after being downloaded
  • JavaScript posts a request that updates the script every time

Q7. How can we cancel the XMLHttpRequest in AJAX?

Ans. Abort() method can be called to cancel the XMLHttpRequest in Ajax.

Q8. Is AJAX code cross browser compatible?

Ans. No, it is supporting cross-browser compatible. If the browsers support native XMLHttpRequest JavaScript object, then this can be used.

Q9. What is the name of the object used for AJAX request?

Ans. XmlHttpRequest object is used for Ajax requests.

Q10. What is an Event Handler?

Ans. An event handler will run a function when something happens, for example, a keystroke or movement of a mouse.

Q11. What Is the Format of an AJAX Request?

Ans.

An AJAX request can be in any format:

  1. Text File
  2. HTML
  • JSON object
  1. What is XHR and What is it used for?

Ans.

XHR stands for XMLHttpRequest. XHR objects, or XMLHttpRequest objects, are used in the following ways:

  • An XHR object is used by JavaScript to transfer XML and other text data between client and server.
  • The XHR object allows a client-side script to perform an HTTP request.
  • AJAX applications use the XHR object so that the browser can communicate with the
  • Server without requiring a post-back or refresh of the entire page.

Note:  Old versions of Internet Explorer (6 and earlier) used MSXML ActiveX instead of XHR to provide this functionality.

Q13. What Is JSON?

JSON stands for JavaScript Object Notation. It is a safe and reliable data interchange format in JavaScript, which is easy to understand, not only for users but also for machines.

Q14. When Should We Avoid Using AJAX?  

Ans.

  • When does a browser not support JavaScript?
  • When do we want to create a secure application?
  • When we want our WebPages to be visible to major search engines like Google, Yahoo, and Bing
  1. Why is AJAX a Problem for Visibility in Search Engines?

Ans. A web crawler does not execute JavaScript code, and AJAX is JavaScript.

  1. Does an AJAX Request Work on Different Domains?

Ans.  No. An AJAX request works only within the same domain.

  1. Is an AJAX Request Synchronous or Asynchronous?

Ans. AJAX requests are asynchronous by nature, which means that they should run in the background independently of other events.

  1. Is AJAX Code Cross-Browser Compatible?

Ans. Not totally. Most browsers offer a native XMLHttpRequest JavaScript object, while old versions of Internet Explorer require you to get it as an ActiveX object.

  1. What Are the Reasons for the Types of Errors Shown Below?

Ans.

  1. XMLHttpRequest cannot load file:///C:/Tutorials/jQuery/practices/ajax/dataFile.txt. Cross origin requests are only supported for HTTP.
  2. Uncaught NetworkError: A network error occurred. An AJAX request cannot be executed without the server. To get a reply, we need to execute the AJAX request into the server. So, if the requested object is missing in the server, the above error could result.

Q20. How Do You Retrieve the State of the Requested Process?

Ans. By using the property “readyState” of XMLHttpRequest object (XHR Object), which uses numeric values to represent the state.

Q21. What does it mean if ReadyState has the Value 0?
Ans. A readyState of 0 means the request hasn’t been sent yet.

Q22. What does it mean if ReadyState has the Value 4?

Ans. A readyState of 4 means the request has seen sent and received.

Q23. What is the Meaning of 404 or 500 Status in AJAX?

Ans. It means that the AJAX call to the server is unsuccessful.

News Reporter
IT Software and web development, Core PHP, JavaScript, JQuery, HTML, CSS, CakePHP, Angularjs, Codeigniter etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: