I have this on my Razor page
Index.cshtml
@for (int i = 0; i < Model.Count(); i++)
{
var cars = Model.ElementAt(i);
<a href="@Url.Action("Cars","Home", new { id = cars.Id })">
}
Now, I am looking to achieve the same functionality using jQuery Ajax in JavaScript.
$.ajax({
type: "Get",
url: '/Cars/Home',
data: {
id: $(this).attr("id")
},
dataType: "json",
success: function (data) {
for (var i = 0; i < data.length; i++) {
html1.push("<a href='Cars/Home', new { id = cars.Id })>");
html1.push("</a>");
}
$("#wraps").html(html1.join(""));
}
})
Despite encountering an error with the current approach, I am determined to figure out how to make it work. Any suggestions on how to tackle this issue would be greatly appreciated.