2011-04-04 117 views
0

我使用jQuery用户界面自动完成与阿贾克斯,这是JSON响应我使用萤火jQuery UI的自动完成不工作

[{"value":" test","url":"\/social\/profile\/46","label":" test"}, 
{"value":" test","url":"\/social\/profile\/47","label":" test"}, 
{"value":"test tset","url":"\/social\/profile\/62","label":"test tset"}, 
{"value":"test test","url":"\/social\/profile\/126","label":"test test"}] 

这是我点的代码

// Using jQuery UI's autocomplete widget: 
    $('#term').autocomplete({ 
     minLength : 4, 
     source  : rootPath+'/search', 
     select: function(event, ui) 
     { 
      window.location = ui.item.url; 
     } 
    }); 

越来越获得自动完成列表

+0

什么id不工作? – 2011-04-04 06:11:21

+0

[请在这里找到演示](http://blogexplorerx.herobo.com/testing/demo.zip) – 2011-04-04 13:05:53

回答

0

与jquery validate 1.7有冲突,所以移动到1.8验证

0

似乎工作

<script> 
$(function() 
{  
    $("#text").autocomplete({ 
      source: "something.php", 
      type:"json", 
      select: function(event, ui) 
      { 
       window.location = ui.item.url; 
      } 
     }); 
}) 
</script> 
<input type="text" name="text" id="text"/> 

对于响应

[{"value":" test","url":"/social/profile/46","label":" test"}, 
{"value":" test","url":"/social/profile/47","label":" test"}, 
{"value":"test tset","url":"/social/profile/62","label":"test tset"}, 
{"value":"test test","url":"/social/profile/126","label":"test test"}] 

我猜的反应应该是"/social/profile/126"而非\/social\/profile\/126"

+0

不,它不工作 – aWebDeveloper 2011-04-04 07:39:50