I am using autosearch textbox in layout page & jquery code jason method call in controller,I am able to autosearch dynamic values from database in home page but when value is selected and redirected to specific page there autosearch is not working(jquery is not calling to jason method).I tried also removing other javascript files and taking a new view file.
("Autosearch textbox is working in home page but when it is redirected to another view Auto search is not happening in textbox.")
Hi saineshwar,i checked through console and the problem is it is not correctly routing to controller and action.below is my routing order.please check it.
var uri = "Home/GetCountry";
<http:
I have put autosearch in layout page and from where ever move to different views i should redirect to 'home'-controller and 'getcounrty'- jason method.Suggest with correct routing order.Thank you
What I have tried:
my jquery code:
var textbox;
var selectValue;
$(function () {
textbox = $("#txtCountrty");
selectValue = $('ul#selectedValue');
textbox.on("input", function () {
getAutoComplete(textbox.val());
});
});
function getAutoComplete(countryName) {
var uri = "Home/GetCountry";
$.getJSON(uri, { countryName: countryName })
.done(function (data) {
selectValue.html("");
var count = 0;
$.each(data, function (key, item) {
var li = $('<li/>').addClass('ui-menu-item').attr('role', 'menuitem')
.html("<a href='' onclick=\"setText('" + item + "')\">" + item + "</a>")
.appendTo(selectValue);
count++;
});
});
}
function setText(text) {
textbox.val(text);
getAutoComplete(text);
}
jason method:
public JsonResult GetCountry(string countryName)
{
MySqlConnection Con = new MySqlConnection(ConfigurationManager.ConnectionStrings["Mysqlcon"].ConnectionString);
DataTable dt;
var ds = new DataSet();