uses of ajax examples
Example 1: ajax example
$.ajax({
method: "POST",
url: "/controller/action",
data: { name: "John", location: "Boston" },
success: (result) => {
console.log(result);
},
error: (error) => {
console.log(error);
}
});
Example 2: $.ajax example
class DB {
private $host = 'localhost';
private $user = 'root';
private $password = '';
private $db_name = 'library';
public $conn;
public function connect() {
$this-> conn = new mysqli($this-> host, $this-> user, $this-> password, $this-> db_name);
return $this -> conn;
}
}