我有這樣的電話:意外的關鍵
bindAutoComplete('pro_title');
使用這個功能進行jQuery的AJAX調用:
function bindAutoComplete(id) {
$("#" + id).keyup(function() {
if (this.value.length > 1) {
$.post("/ajax/autocomplete" , {id: this.value }, function(data) {
// do stuff here...
});
}
});
}
,與此PHP腳本:
public function autocompleteAction()
{
if ($this->getRequest()->isPost()) {
echo print_r($this->getRequest()->getPost());
}
}
當我運行這些腳本時,PHP回聲:
Array ([id] => test) 1
這裏的'測試'是來自AJAX調用的this.value
中的值。
我在找什麼是[id]
將被替換爲pro_title
。
請幫忙!
你是什麼意思?只需用'{pro_titile:this.value}'替換'{id:this.value}'' –
'爲什麼你有'echo print_r('?這裏你不需要'print_r',這是毫無意義的。 –
@Rocket因爲我正在測試print_r沒有生產 – tjb1982