2010-01-23 147 views
1

參照this postthis one。我試圖實現標籤搜索我的博客/網站類似SO標籤系統使用jquery autocomplete plugin,我使用jquery 1.4最新版本,所以我不知道它是否適用它,我用這個插件之前一次。因此,沒有進一步jibr - 賈布爾這裏是我的自動完成HTML:jquery自動完成jquery 1.4

<input id="post-tags" class="ac_input" type="text" autocomplete="off" value="" name="post_tags"/> 

這裏是我的javascript:

<script type="text/javascript"> 
    $(document).ready(function(){ 

function findValueCallback(event, data, formatted) { 
    $("<li>").html(!data ? "No match!" : "Selected: " + formatted).appendTo("#result"); 
} 

function formatItem(row) { 
    return row[0] + " (<strong>id: " + row[1] + "</strong>)"; 
} 
function formatResult(row) { 
    return row[0].replace(/(<.+?>)/gi, ''); 
} 

$("#post_tags").autocomplete("http://localhost/tags/filter/", { 
    width: 260, 
    selectFirst: false 
}); 

$("#clear").click(function() { 
    $(":input").unautocomplete(); 
}); 


    }); 
    </script> 

我敢肯定,我的PHP的一部分是確定的,它是這樣工作的,當我manualy類型網址http://localhost/tags/filter/p

我返回如下:

php (1) 
asp (1) 

含義所有標籤ç現在我只有這兩個。我的問題是,我做錯了什麼,我真的被困在這個問題上,我已經改變了很多次,現在我想不出任何我想做的事情。謝謝

回答

1

的技巧是使用POST而不是獲得,使用得到/被刪除,但使用時後完整的東西穿過,從而自動完成需要一定的調整(額外的一條線)時,這就是:

$.ajax({ 
       type: "post", // This is the new line 
       // try to leverage ajaxQueue plugin to abort previous requests 
       mode: "abort", 
       // limit abortion to this input 

現在一切都像一個魅力工作..