Unable to pass id to js function
This is a table element:
<tbody>
@for (int i = 0; i < @Model.Count; i++)
{
<tr onclick="GetOrder('@Model[i].Id')">
<th scope="row">@(i + 1)</th>
<td>@Model[i].Number</td>
<td>@Model[i].Date.ToString("d")</td>
<td>@Model[i].ProviderName</td>
</tr>
}
</tbody>
JS function:
function GetOrder(id) {
$.ajax({
url: "/Orders/GetOrder",
type: "POST",
data: { orderId: id }
});
The HTML code is generated: <tr onclick="GetOrder('1')">
. And the call passes to the controller method. But in js, the id parameter is always =0, data=null, and '0' always comes to the controller method. In another project, similar code worked, but that project was on net5, and this one on net6, and this is the only difference. What could be the matter here?
Comments
Post a Comment