use ajax with php code example

Example 1: ajax php

$.ajax({
                type: "POST",
                url: "event.php", 
                data:"action=chnageChart&value1="+id,
                cache: false, 
                success: function(html){  
                    window.location.reload();
                }
            });

Example 2: ajax call php

$.ajax({ url: '/my/site',
         data: {action: 'test'},
         type: 'post',
         success: function(output) {
                      alert(output);
                  }
});

Example 3: ajax jquery php

$.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);

 });

Tags:

Php Example