i want to create dynamic textbox which fetch data from database table using jquery ajax in mvc4,i have done it..here is my code
public JsonResult AutoCompleteTasks(string term)
{
var result = (from t in pc.Tasks
where t.Name.Contains(term)
select new { t.Name }).Distinct();
return Json(result, JsonRequestBehavior.AllowGet);
}
and here is ajax,
$("#textarea").autocomplete({
source: function(request,response) {
$.ajax({
url: "/Home/AutoCompleteTasks",
type: "POST",
dataType: "json",
data: { term: request.term },
success: function (data){
{
if(data){
alert(data.FirstMidName);
$("#textarea").val(data.FirstMidName);
}
response($.map(data, function (item) {
return { label: item.Name, value: item.Name };
}))
}
})
},
messages: {
noResults: "", results: ""
}
});
but now i want a textbox which can fetch more than 1 entry separted by commas,like this
task1,task2,task3 in textbox ,how can i do that,,,,,