我使用Jquery 自动完成,我有以下代码:
客户端:
$( "#tags" ).autocomplete({
source: function(request, response) {
$.ajax({
url: "get_professionals",
data: request,
dataType: "json",
type: "POST",
success: function(data){
alert("hello");
}
});
}
});
服务器端:
function get_professionals() {
if ($_POST["term"]):
$professionals = Professional::find('all', array('conditions' => "name LIKE '%" . $_POST["term"] . "%'"));
foreach ($professionals as $professional):
echo $professional->to_json();
endforeach;
endif;
}
URL 是正确的,事实上,我从服务器获得了结果(我在“post”选项卡中从 Firebug 中检查了它)但没有显示