jquery with ajax example

Example 1: ajax jquery example

$.ajax({

   url     : "file.php",
   method  : "POST",

       data: { 
         //key                      :   value 
         action                   	:   action , 
         key_1   					:   value_key_1,
         key_2   					:   value_key_2
       }
   })

   .fail(function() { return false; })
	// Appel OK
   .done(function(data) {

   console.log(data);

 });

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;

		
	}

}

Tags:

Misc Example