DEV Community

loading...

How to use Ajax in PHP with JQuery

theinspirespy profile image sid sharma ・1 min read

Ajax is called (Asynchronous JavaScript and XML) , It is used when we want to send data into database or recieve data from database without reloading the whole page.

Example :

  1. Promocode in ecommerce website , when user applied promocode in ecommerce website , after successfully applied webpage not reloading just showing coupon applied message to us.

  2. When we want to recieve complete data of employee or patient on behalf of employee id or patient id without page refreshing

There are number of examples in ajax just keep one point in your mind is that when we want data or send data without page reload.

Solution :

HTML Code :


Rakesh kumar
Rajesh kumar
Deepak Mathur

Jquery Code :
$('#selectdata').change(function () {

$enqid = $('#empid').val();

$.ajax({
url:"php page url",
method:"POST",
data:{empid:$empid},
success:function(data)
{
if(data)
{
$('#searchdiv').html(data);
}
else
{

}

}
});

any Problem just contact us at Contact us

Discussion (0)

pic
Editor guide