I am using jQuery UI Autocomplete on my Create View in my web application
When I click in the textbox that I want the autocomplete to service, and type 1 letter, I receive a runtime error:
Here is the line of the built in script debugger where the error is occurring
Here is my Script:
<script type="text/javascript">
$(document).ready(function () {
$('#Categories').autocomplete({
source: function (request, response) {
$.ajax({
url: "/Activities/AutoCompleteCategory",
type: "POST",
dataType: "json",
data: { term: request.term },
success: function (data) {
response($.map(data, function (item) {
return { label: item.subcategory, value: item.subcategory };
}))
}
})
},
messages: {
noResults: "", results: ""
}
});
})
</script>
Here is my Controller:
public JsonResult AutoCompleteCategory(string term)
{
var result = (from r in db.Activities
where r.subcategory.ToUpper().Contains(term.ToUpper())
select new { r.subcategory }).Distinct();
return Json(result, JsonRequestBehavior.AllowGet);
}
If I click Do not show this message again, it works perfectly.
Any help to figure out why this run-time error is happening is greatly appreciated.

