jquery autosuggest: what is wrong with this code?
Posted
by Abu Hamzah
on Stack Overflow
See other posts from Stack Overflow
or by Abu Hamzah
Published on 2010-04-30T19:51:54Z
Indexed on
2010/04/30
19:57 UTC
Read the original article
Hit count: 222
autocomplete
|jQuery
i have been struggling to make it work my autosugest/autocomplete and its acting strange unless i am doing completely silly here.
please have a look
1) does not do anything, does not work or nor fire the event.
<script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script>
<script src="Scripts/jquery.autocomplete.js" type="text/javascript"></script>
<form id="form1" runat="server">
<script type="text/javascript">
$(document).ready(function() {
$("#<%=txtHost.UniqueID %>").autocomplete("HostService.asmx/GetHosts", {
dataType: 'json'
, contentType: "application/json; charset=utf-8"
, parse: function(data) {
var rows = Array();
debugger
for (var i = 0; i < data.length; i++) {
rows[i] = { data: data[i], value: data[i].LName, result: data[i].LName };
}
return rows;
}
, formatItem: function(row, i, max) {
return data.LName + ", " + data.FName;
}
});
});
</script>
2) this works if i remove the above code and replace with this code:
<script type="text/javascript">
$(document).ready(function() {
$("#txtHost").autocomplete("lazy blazy crazy daisy maisy ugh".split(" "));
});
</script>
any help ?
© Stack Overflow or respective owner