AJAX WITH PHP
Definition
•AJAX (Asynchronous JavaScript and XML) is a technique used to send and
receive
data from the server without reloading the webpage.
• It allows faster and smoother web applications.
FeaturesofAJAX
•No page refresh needed
•Faster data exchange
•Improves user experience
•Works in background.
WorkingofAJAXwithPHP
1.User sends request (button click / input)
2.JavaScript (AJAX) sends request to
server
3.PHP processes the request
4.PHP sends response
5.AJAX updates the webpage
Syntax (AJAX – JavaScript)
Var xhttp = new XMLHttpRequest();
Xhttp.onreadystatechange = function() {
If (this.readyState == 4 && this.status == 200) {
Document.getElementById(“demo”).innerHTML = this.responseText;
}