English 中文(简体)
Jquery autocomplete with jquery 1.4
原标题:

Referring to this post and this one. I m trying to implement tag search for my blog/website something similar to SO tag system using jquery autocomplete plugin, I m using jquery 1.4 latest version so I m not sure whether it works with it or not, I ve used this plugin before once. So without further jibr-jabr here is my html for autocomplete :

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

Here is my 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> 

I m sure my php part is ok, it works like this when I manualy type the url http://localhost/tags/filter/p

I returns the following :

php (1)
asp (1)

Meaning all tags containing p, for now I have only these two. My question is, what am I doing wrong, I m really stuck on this one, I ve changed things around so many times now I can t think of anything new I d like to do. Thank you

最佳回答

The trick is to use post instead of get, when using get / gets erased but when using post complete thing is passed so the autocomplete needs some adjustments(extra one line) here it is :

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

Everything worked like a charm now..

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签