How to use Ajax in PHP

To use ajax, I will use jQuery. See the following code.


jQuery.ajax({

url:"ajax.php",

data:{val1:value1,val:value2},

success:function(response){

do something after success 
} 

});

 

Now in ajax.php you can get the request data.


<?php

$value1= $_REQUEST['val1'];

$value2= $_REQUEST['val2'];

?>

Leave a Reply