What is the main advantage of using AJAX to access a database?
A
It improves database storage
B
It reduces server security
C
It allows data retrieval without reloading the page
D
It encrypts database records
Analysis & Theory
AJAX allows asynchronous communication, letting users interact with the database without reloading the web page.
Which server-side language can be used with AJAX to interact with a database?
Analysis & Theory
`PHP` (as well as ASP, Node.js, etc.) can handle server-side logic and interact with the database in response to AJAX requests.
Which SQL operation is most often used with AJAX to fetch data?
Analysis & Theory
`SELECT` queries are used to fetch data from the database, which is common in AJAX interactions.
Which AJAX method is best for sending large amounts of data to the server?
Analysis & Theory
`POST` is preferred for sending large or sensitive data securely to the server.
How is the response from the server typically handled after an AJAX request?
A
It is written directly to the database
B
It is passed to a callback function
C
It is stored in a cookie
Analysis & Theory
AJAX uses callback functions to handle responses from the server.
Which format is commonly used to exchange data between AJAX and server/database?
Analysis & Theory
XML and JSON are both commonly used formats for exchanging data between client and server using AJAX.
How can you parse a JSON response from a server in JavaScript?
C
JSON.parse(responseText)
D
JSON.decode(responseText)
Analysis & Theory
`JSON.parse()` is used in JavaScript to convert a JSON string into a JavaScript object.
What is the risk if you don’t sanitize user input before sending it to the database via AJAX?
Analysis & Theory
Unvalidated input can allow SQL Injection, a major security vulnerability when interacting with databases.
Which part of an AJAX call sends data to the server?
Analysis & Theory
`xhr.send()` is used to send the AJAX request (along with any data) to the server.
Which function can be used to update the HTML content dynamically after receiving data from the database?
D
document.getElementById().innerHTML
Analysis & Theory
`document.getElementById('id').innerHTML` is used to update page content dynamically after getting a server response.