I have a jQuery UI which is doing simple autocomplete function. Autocomplete is coming via Web Service.
This is the sample of my jQuery:
<script type="text/javascript">
$(document).ready(function () {
$('[id$="tbSearch"]').autocomplete({
url: '/WebService/SearchLookUp.asmx/ReturnEntity',
width: 300,
max: 10,
delay: 100,
cacheLength: 1,
scroll: false,
highlight: false
});
});
And this is the sample of my web service:
public class SearchLookUp : System.Web.Services.WebService
{
[WebMethod]
public string []ReturnEntity(string prefixText)
{
using (TestDataContext search = new TestDataContext())
{
var tr = from p in search.Entities
where p.Name.StartsWith(prefixText)
select p.Name;
return tr.ToArray<string>();
}
}
}
When I am running this web service in the browser and passing parameters: ‘ST’ I am getting these results:
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<string>Steve</string>
<string>Star</string>
<string>Steve D</string>
<string>Star Route</string>
<string>Staffing</string>
<string>Strategic</string>
<string>Staci</string>
<string>Stevens</string>
<string>Starr</string>
</ArrayOfString>
Now the problem is that as soon I am entering anything on my textbox (tbSearch) I am getting MS jScript Error: Object Expected in
jQuery-ui-1.8.11.custom.min.js
At line this:
{this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)}
You may need to check your syntax on the autocomplete object
based on this TextBox AutoComplete with ASP.NET and jQuery UI
source:method is built to call the ajax, looks like you also need to specify thedata:to be sent to the web service