ajax request 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 to php call
$.ajax({ url: '/my/site',
data: {action: 'test'},
type: 'post',
success: function(output) {
alert(output);
}
});
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'test' : test();break;
case 'blah' : blah();break;
}
}
Example 3: ajax call php
$.ajax({ url: '/my/site',
data: {action: 'test'},
type: 'post',
success: function(output) {
alert(output);
}
});