我有一个jquery自动完成功能,但是如果它的数据源是json,那么它会在自动建议列表之间添加一个空格。如下所示。请帮助删除额外的空间。 我从ajax.aspnetcdn使用jquery.ui / 1.11.4 / themes / black-tie / jquery-ui.css,jquery-2.1.4.js和jquery.ui / 1.11.4 / jquery-ui.min.js .com CDN 感谢。Image of auto suggested list output from json
我正在使用的代码是
$term=$_GET["term"];
$getIt ='%'.$term.'%';
$sql = "SELECT first_name, last_name, tel_no, location FROM drivers WHERE first_name like ? ORDER BY first_name limit 10";
if($getDriv = $con->prepare($sql)){
$getDriv-> bind_param('s', $getIt);
$getDriv-> execute();
$getDriv-> bind_result($fName, $lName, $telNo, $loc);
}
$json=array();
while($getDriv ->fetch()){
$json[]=array($driv['value']= $fName,
$driv['label']= $fName,
$driv['lName']= $lName,
$driv['tel']= $telNo,
$driv['loc']= $locs
);
array_push($json, $driv);
}
echo json_encode($json);
和jquery
$(document).ready(function() {
$("#firstName").autocomplete({
delay: 0,
source: 'auto_driver.php',
minLength: 1,
select: function(event, ui) {
$("#firstName").val(ui.item.value);
$("#lastName").val(ui.item.lName);
$("#telNo").val(ui.item.tel);
$("#location").val(ui.item.loc);
}
});
});

答案 0 :(得分:0)
更改此
public void WriteToXLST(SQLStructure oStructure, string sFilenamePath)
{
string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.15.0;" +
"Data Source={0};Extended Properties='Excel 15.0;HDR=YES;IMEX=0'", sFilenamePath);
using (OleDbConnection cn = new OleDbConnection(connectionString))
{
cn.Open();
foreach (string sInsertString in oStructure.InsertsList)
{
OleDbCommand cmd1 = new OleDbCommand(sInsertString, cn);
cmd1.ExecuteNonQuery();
}
cn.Close();
}
}
这解决了我的问题
$json[]=array($driv['value']= $fName,
$driv['label']= $fName,
$driv['lName']= $lName,
$driv['tel']= $telNo,
$driv['loc']= $locs
);
array_push($json, $driv);