$.ajax({
url: "/Home/GetAllSearchData",
datatype: "json",
type: "get",
data: {
text: Search,
city: city,
locality: locality
},
success: function(data) {
if (data.result != null) {
$("#table").find("tr:not(:first)").remove();
var tr;
for (var i = 0; i < data.result.length; i++) {
var res = [];
res = data.result[i].Id.split(",");
tr = $('<tr/>');
tr.append("<td>" + " <div class='dashboardmodal - body'><p><a href='@Url.Action("
SearchAction ", "
Home ", new { city = city })'>" + data.result[i].name + "</a></p>" + "</div></td>");
$('#table').append(tr);
}
var modal = document.getElementById('myModal');
modal.style.display = "block";
}
},
error: function(err) {
alert(err);
}
});
I am trying to pass city variable value to anchor tag parameter but getting error the name does not exist in the current context
Better change the object name city to cityObj and then try passing the same .. or just try the below one and check in console
'@Url.Action("SearchAction", "Home")?city=' + city +
or your could try the below,
'@Url.Action("SearchAction", "Home")', { city: city }
Hope it helps !!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.