AJAX Questions Flashcards

1
Q

What are the security issues with AJAX?

A
  1. Cross-Site Scripting (XSS): AJAX requests can be vulnerable to XSS attacks if proper input validation and output encoding measures are not implemented. If user-generated data is directly incorporated into AJAX requests without proper sanitization, an attacker can inject malicious scripts into the response, potentially compromising the user’s browser and stealing sensitive information.
  2. Cross-Site Request Forgery (CSRF): AJAX requests are susceptible to CSRF attacks if appropriate CSRF protection mechanisms are not in place. Without proper validation and verification, an attacker can trick a user’s browser into making unintended AJAX requests to a target website, potentially leading to unauthorized actions being performed on behalf of the user.
  3. Insecure Data Transmission: AJAX requests must be sent securely over HTTPS to protect sensitive data from interception and tampering. If AJAX requests are transmitted over an insecure HTTP connection, the data being sent, including user credentials or sensitive information, can be exposed to eavesdropping or manipulation.
  4. Information Leakage: AJAX responses may contain sensitive information that should not be disclosed to unauthorized users. Developers need to ensure that sensitive data is not unintentionally exposed in AJAX responses, such as through error messages or debugging information, as it can provide valuable insights to potential attackers.
  5. Server-Side Validation: AJAX should not be relied upon as the sole method of data validation. Client-side validation with AJAX can be bypassed by attackers, so it is essential to perform robust server-side validation and input sanitization to prevent malicious data from being processed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the differences between synchronous and asynchronous requests?

A

A synchronous client constructs an HTTP structure, sends a request, and waits for a response. An asynchronous client constructs an HTTP structure, sends a request, and moves on.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of XMLHttpRequest?

A

XMLHttpRequest (XHR) objects are used to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the role of a callback function in AJAX?

A

Callback functions are used to handle responses from the server in Ajax. A callback function can be either a named function or an anonymous function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

List some tools available for debugging AJAX applications.

A

Chrome DevTools, Browser Extensions, Fiddler, Postman, Wireshark.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between JavaScript and AJAX?

A

AJAX = Asynchronous JavaScript And XML.

AJAX is not a programming language.

AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the different ready states of a request in AJAX?

A

In JavaScript, there are four different ready states of an AJAX request: unsent, opened, headers received, and done.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the types of postback in AJAX?

A

There are two types of postbacks in AJAX, which are synchronous postback and asynchronous postback.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain JSON in AJAX.

A

JSON is the best language for exchanging data due to its characteristics and simplicity. AJAX is a method of web development used to build interactive web applications. Web pages can request data from servers using AJAX without reloading the page. The JSON format is one that the AJAX technique uses to represent data.

Advantages of using JSON instead of XML in AJAX:

The Code of JSON will be short in comparison to XML that’s why transferring data will be smooth
JSON is easier to understand in comparison with XML
In JSON we can easily represent a NULL Value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you test AJAX code?

A
  • Manual Testing: manually triggering events and checking if the expected behaviors occurs.
  • Browser DevTools: like chrome, Firefox etc
  • Unit Testing: Jasmine, Mocha, etc
  • End to End Testing: Selenium to simulate user interactions and check the resulting behavior
    Using a Testing Framework: Testing frameworks like Jest, Chai, Enzyme.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly