Below is my php file to apply query
    $host = "localhost";
    $user = "root";
    $pass = "abc123";
    $databaseName = "class";
    $con = mysql_connect($host,$user,$pass);
    $dbs = mysql_select_db($databaseName, $con);
    $result = mysql_query("SELECT id, name FROM lecturer");
    if (mysql_num_rows($result)) {
        $data = array();
        while ($row = mysql_fetch_assoc($result)) {
            $data[] = array(
               'id' => $row['id'],
               'name' => $row['name']
            );
        }
        header('Content-type: application/json');
        echo json_encode( $data );  
    }  
And this is my other file where i am applying javascript. I have searched a lot of same queries but could not find solution. Please help me
    <script type="text/javascript">
        function lecturer(){
            $("#a1_title").empty();
            $("#a1_title").append("<option>Default</option>");
            $.ajax({
                    type:'POST',
                    url : 'get-data.php',
                    contentType :"application/json; charset-utf8",
                    dataType:'json',
                    type:'POST',
                    success:function(data){
                        $('#a1_title').empty();
                        $('#a1_title').append("<option>Default</option>");
                        $.each(data, function(i, data){
                            $('#a1_title').append('<option   value="'+data[i].id+'">'+data[i].name+'</option>');
                        });
                    },
                    complete: function(){
                    }
            )};
        }
        $(document).ready(function(){
            lecturer();
        });
    </script>
Please help me I have tried to solve this problem buy i am not able to do it.
 
    