我实际上正在为我的表单中的名称开发自动完成功能。JqueryUI自动完成PHP JSON
这里是我的jQuery代码:
$page->appendJs(<<<JS
$(document).ready(function()
{
$.ajax({
url: 'jsonClients.php',
type: 'POST',
dataType: 'json',
data: 'client' : $("#client").val(),
success: function(data){
$('#client').autocomplete(
{
source: data,
minLength: 1
});
}
});
});
JS );
我输入
<input type='text' id='client' name='client'>
我jsonClients.php工作,它需要一个客户端的参数。 我从来没有做过任何jquery,所以我有点失落。
编辑:
的Json
$json = array();
while($client = $requete->fetch()) {
array_push($json, array('nom' => $client['CLI_NOM']));
}
echo json_encode($json);
感谢您的帮助
参数通过'data:'选项发送。 – j08691 2015-04-03 13:55:17