ajax call to retrieve the data from database example using jquery


         <script type="text/javascript">
 $(document).ready(function() {
         $('.name').blur(function() {
                type: "GET",
                 dataType: "json",
                   url: "ajax_info.php",
                     data: "name="+$(this).val(),
                       success: function(json){

     <label>Name</label><input type="text" id="name" name="name" value="" >
     <label>Mobile Number</label><input type="text" id="number" name="number" value="" >


<?php include('config.php');
$mobile_num = ' ';

$sql="SELECT customer_name FROM customer WHERE customer_name = '".$name."'";
$result = mysql_query($sql);

if(mysql_num_rows($result) > 0){

$sql="SELECT mobile_num FROM customer WHERE customer_name = '".$name."'";
$result = mysql_query($sql);
$row  = mysql_fetch_array($result);
$mobile_num = $row['mobile_num'];



If you are giving name in first text box and on blur the mobile number fills automatically, I think it may be helpful. Thanks.

This entry was posted in Ajax, Jquery, PHP and tagged , . Bookmark the permalink.
  • John


  • John

    I am new Can u please provide me the complete source of this..