my php function
<?php
    function handleException($ex)
      {
        header('HTTP/1.1 500 Internal Server Error');
        echo 'Internal error';
     }
    set_exception_handler('handleException');
    // we are using PDO -  easier to use as mysqli and much better than the mysql extension (which will be removed in the next versions of PHP)
     try 
     {
        $password = 'root';
        $db = new PDO('mysql:host=localhost;dbname=finance', "root", $password);
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    mysql_set_charset('utf8');
        // note the quote thing - this prevents your script from sql injection
        mysql_query('SET NAMES utf8;');
        $data = $db->query("SELECT customer_name FROM customer where customer_id = " . $db->quote($_GET["q"]));
        $customer_name = array();
        foreach ($data as $row) {
           $customer_name[] = $row["customer_name"];
        }
        print json_encode(array(
                "customer_name" => $customer_name,
                "anotherReturnValue" => "just a demo how to return more stuff")
        );
    } catch (PDOException $e) {
        echo 'ERROR: ' . $e->getMessage();
    }
    ?>
and my php form file
<?php include('header.php');
include('config.php');
<div>
  <form id="form" method="post" action="functions/adduser.php" enctype="multipart/form-data" >
     <table>
     <tr><td>உ.எண்</td>
     <td>
        <select id="sno" name="sno" >
        <option>உ.எண்</option>
        <?php while($row=mysql_fetch_array($result))
      {?>
           <option value="<?php echo $id=$row['customer_id'];?>" id="sno"><?php echo $id=$row['customer_id'];?></option><?php }?>
        </select>
     <td><div  id="list"></td></tr>
     <tr>
        <td><label>பெயர்</label></td>
        <td>
         <input type="text" value="" name="name" id="" class="text">
        </td>
      </tr>
     <tr>
        <td><label>ஊர்</label></td>
        <td>
         <input type="text" value="" name="city" class="text">
        </td>       
      </tr>
     <tr>
      <tr>
        <td><label>பற்று</label></td>
        <td>
         <input type="text" class="text" name="loan"></textarea>
        </td>
      </tr>
     <tr>
        <td><label>ஆரம்பம் தேதி</label></td>
        <td>
          <input type="text" class="text" name=""  value="<?php echo date('Y-m-d'); ?>" />
        </td>
      </tr>
       <tr>
        <td><label>முடிவு தேதி</label></td>
        <td>
         <input type="text" class="text" name="" value="<?php echo $end_date; ?>" />
        </td>
      </tr>
      <tr><td><input type="button" value="Save" id="save" name="save" class="text"></td></tr> 
      <tr><td><div id="error"></div></div></td></tr>
      </table>
  </form>
</div>
    <script tyep="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" charset="UTF-8">
        $(document).ready(function () {
            // if user chooses an option from the select box...
            $("#sno").change(function () {
                // get selected value from selectbox with id #department_list
                var cusno = $(this).val();
                $.ajax({
                    url: "functions/get_name.php",
                    data: "q=" + cusno,
                    contentType: "application/json; charset=utf-8",
                   dataType: "json",
                    // if successful
                    success: function (response, textStatus, jqXHR) {
                        // no teachers found -> an empty array was returned from the backend
                       if (response.customer_name.length == 0) {
                            $('#result').html("nothing found");
                       }
                       else {
                            // backend returned an array of names
                          var list = $("#list");
                            //remove items from previous searches from the result list
                           $('#list').empty();
                            //append each teachername to the list and wrap in <li>
                                $.each(response.customer_name, function (i, val) {
                                //list.append($("<li>" + val + "</li>"));
                           });
                       }
                        $.each(response.customer_name, function (i, val) {
                        });
                    }});
            });
            // if anywhere in our application happens an ajax error,this function will catch it
            // and show an error message to the user
            $(document).ajaxError(function (e, xhr, settings, exception) {
                $("#error").html("<div class='alert alert-warning'> Uups, an error occurred.</div>");
            });
        });
    </script>
    </script>
<?php include('footer.php');?>
 
     
     
     
    