You are made ajax request, but do nothing with result data.
Try this
$(document).ready(function(){
$("#select").change(function(){
var selectid = $(this).val();
// using post method to get firstname
$.post("retreive.php", {selectid:selectid}, function(result){
$("#fname").val(result);
//again using post method here get lastname
$.post("one.php", {selectid:selectid}, function(result){
$("#lname").val(result);
});
});
});
});
You don't need two ajax requests - you can make one request, and get json data.
Read about jquery ajax method and json format
$(function(){
$('#select').change(function(){
var selectid = $(this).val();
$.ajax({
url: 'retreive.php',
data: {selectid: selectid},
type: 'POST',
dataType: 'JSON',
success: function(data)
{
$("#fname").val(result.fname);
$("#lname").val(result.lname);
}
});
});
});
And php
<?php
if (isset($_POST['selectid'])) {
echo json_encode(array('fname' => $fname, 'lname' => $lname));
exit;
}
And if something goes wrong, when you made ajax request, open console, and find errors. If you have no errors, go for the network and see what server returns you.