Docsity

Ajax -programming in php, Summaries of Computer Programming

Toggle sidebar
bg1
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;
}
pf3
pf4

Partial preview of the text

Download Ajax -programming in php and more Summaries Computer Programming in PDF only on Docsity!

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; }

Xhttp.open(“GET”, “server.php”, true); Xhttp.send(); PHP File (server.php)

Simple Example

HTML + AJAX

Click Me

  • Fast response
  • Better UI/UX
  • Saves bandwidth
  • Asynchronous processing Disadvantages
  • Depends on JavaScript
  • Debugging is difficult
  • Security issues possible