1
<script type="text/javascript">
$(function() {
$("#customers").autocomplete({
source: 'search.php'
});
});
</script>
<div class="ui-widget"><input id="customers" name="Cno" placeholder="Customer Name"></div>
的search.phpJQuery用戶界面自動填充緩慢選擇的元素
<?php include('header.php');
//get search term
$searchTerm = $_GET['term'];
//get matched data from skills table
$query = $db->query("SELECT * FROM customers WHERE Customer_Name LIKE '%".$searchTerm."%' ORDER BY Customer_Name ASC");
while ($row = $query->fetch_assoc()) {
$data[] = $row['Customer_Name'];
}
//return json data
echo json_encode($data);
?>
對於某些陣列如我在Jquery UI not working properly for some words描述並添加此代碼
$mysqli->set_charset('utf8mb4')
然後將其不工作細我從下拉列表中選擇元素時遇到問題,將li類轉換爲ui-state-active需要很長時間,如何解決它?
任何幫助將是偉大的!
首先,您的PHP代碼易受SQL注入攻擊。當您查看您的JS控制檯時,您是否看到GET請求是否異常長?您可能需要添加'minLength:3'來幫助減少返回的結果集。 – Twisty