i have bellow script fro autocomplete tex box , the fucntion in controller take parameter (prifix )
the script return all data how i can pass the prifix from ajax to controller for example when i type (a) it retuen all data start or not statrt with (a)
this is the script
the script return all data how i can pass the prifix from ajax to controller for example when i type (a) it retuen all data start or not statrt with (a)
this is the script
//var data2 = ["Ahmad Hoshya", "Amani Mustafa", "Maamoun Zakarneh", "Sabeel"];
var data2;
//var firstname = $('#CountryName').val();
var firstname = document.getElementById("CountryName").value;
$.ajax({
url: '/Home/GetRecord?prefix='+ firstname,
dataType: "json",
type : "post" ,
data: data2,
success: function (data) {
data2 = data;
},
error: function (xhr, status, error) {
alert("Error");
}
});
$('#CountryName').autocomplete({
data: { search: $("#searchInput").val() },
source: function y(request, response) {
response($.map(data2, function (item) {
return {
label: item.t,
value: item.t
}
}));
}
,
select: function (e, ui) {
e.preventDefault();
$(this).val(ui.item.label);
$('#CountryID').html(ui.item.value);
}
});
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nisha RegilPosted Sep 7, 2020, 4:24 AM
Laxmidhar SahooPosted Sep 6, 2020, 11:35 AM