try it
function auto_fill(){
$.getJSON("./auto_fill.php?id_num=" + $("#id_num").val(),
function(data){
$.each(data, function(i,item){
if (item.field == "first_name") {
$("#f_name").val(item.value);
} else if (item.field == "phonenum") {
$("#phn_no").val(item.value);
}
});
});
}
auto_fill.php
$id = $_GET['id_num'];
$json = array(array('field' => 'first_name',
'value' => 'Your name'),
array('field' => 'phonenumber',
'value' => $phn),
array('field' => 'somethinglikeDiscription',
'value' => 'You entered ID as '.$id));
echo json_encode($json );
you can pass any variable to these values ββwith this JSON array.
source
share