$.ajax method code example
Example 1: ajax request
$.ajax({
url : 'more_com.php', //PHP file to execute
type : 'GET', //method used POST or GET
data : {variable1 : "some data"}, // Parameters passed to the PHP file
success : function(result){ // Has to be there !
},
error : function(result, statut, error){ // Handle errors
}
});
// NOTE : Parameters will be available either through $_GET or $_POST according
// to the method you choosed to use.
// Here you will get your variable "variable1" this way : $_GET['variable1']
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;
}
}