Как передать скрытый идентификатор с помощью JSON в JQuery UI автозаполнения?

возможно, это дубликат, но я не могу найти решение, поэтому я разместил этот вопрос. Я использую jquery ui для окна автозаполнения поиска. это работает нормально, но проблема в том, что я хочу искать, используя id.example: когда пользователь вводит paris, я пытаюсь отправить city_id в mysql для поиска. так проблема в том, как передать скрытый идентификатор с помощью JSON?
вот код:

 <input type="text" name="grno" id="grno" class="input" title="<?php echo $lng['vldgrno'];?>

jquery code:

<script>
 $(function() {
function split( val ) {
  return val.split( /,\s*/ );
}
function extractLast( term ) {
  return split( term ).pop();
}

$( "#grno" )
  // don't navigate away from the field on tab when selecting an item
  .bind( "keydown", function( event ) {
    if ( event.keyCode === $.ui.keyCode.TAB &&
        $( this ).data( "ui-autocomplete" ).menu.active ) {
      event.preventDefault();
    }
  })
  .autocomplete({
    source: function( request, response ) {
      $.getJSON( "pages/search.php", {
        term: extractLast( request.term )
      }, response );
    },
    search: function() {
      // custom minLength
      var term = extractLast( this.value );
      if ( term.length < 1 ) {
        return false;
      }
    },
    focus: function() {
      // prevent value inserted on focus
      return false;
    },
    select: function( event, ui ) {
      var terms = split( this.value );
      // remove the current input
      terms.pop();
      // add the selected item
      terms.push( ui.item.value );
      // add placeholder to get the comma-and-space at the end
      terms.push( "" );
      this.value = terms.join( "," );
      alert(data.id);
      return false;
    }
  });
  });
  </script>

autocomplete.php :

<?php
  mysql_connect('localhost','root','');
 mysql_select_db('school');
 $return_arr = array();
 $term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends
 //create select query
  $query = "select `grno`,`first_name`,`student_id` from `tbl_student` where `grno` like '%".$term."%' or `first_name` like '%".$term."%'";
  // Run the query
  $result = mysql_query ($query);
  $array = array();
 while($obj = mysql_fetch_array($result)){
 $array['name'] = $obj['first_name']."(".$obj['grno'].")";
 array_push($return_arr,$obj['first_name']."(".$obj['grno'].")");
 }  
 $json = json_encode($return_arr);
 echo $json;
 ?>

как пройтиstudent_id вautocomplete.php, как метка и значение. {label = 'xyz' value = '1'}

Ответы на вопрос(1)

Ваш ответ на вопрос