我需要附加jquery函數的結果。 當用戶鍵入搜索字段時,會調用一個函數,並從我的數據庫返回數據。 我可以使用提醒功能看到返回的數據jquery自動完成onkey功能
<input type="text" name="symbol" id="symbol" required="required" onkeyup="findmatch();">
稱爲jQuery函數低於
function findmatch(){
var symbol= document.getElementById("symbol").value;
$.post("portfolio/searchStock.php",
{
search:symbol
},
function(data,status){
alert(data);
});
}
我需要把數據返回給被像自動完整而我一直在使用中的以下嘗試的功能,我不明白爲什麼它不工作
$("#symbol").autocomplete({
source: data
});
PHP文件的回聲數據如下
if (isset ($_POST['search'])){
$ search = $ _POST ['search']; if(!empty($ search)){ $ query =「select * from companylist where symbol like'」.mysql_real_escape_string($ search)。「%'」; $ query_run = mysql_query($ query);
while ($query_row = mysql_fetch_assoc($query_run)){
$symbol = $query_row['symbol'];
echo $symbol;
}
}
}
你能也粘貼在返回數據的格式? – 2013-03-25 14:34:10