this is my script
<script>
$(document).ready(function () {
$("#PlanVenta").change(function () {
$("#Precio").empty();
$.ajax({
type: 'POST',
url:'@Url.Action("PreciosPorTipoVenta")',
datatype:'json',
data: { Id_Plan: $("#PlanVenta").val(), Id_Articulo: $("#Id_Articulo").val() },
success: function (precios) {
$("#Precio").val(precios[0].precio);
},
});
});
});
</script>
and this is what it contains
This is my Controller where I receive an integer
public JsonResult PreciosPorTipoVenta(Venta_Detalle vd, int Id_Plan,int Id_Articulo)
{
}
<table class="table table-striped">
<tr>
<th>
<label>Articulo</label>
</th>
<th>
<label>Nombre</label>
</th>
<th>
<label>Precio</label>
</th>
</tr>
@foreach (var v in Model)
{
<tr>
<td>
<input type="hidden" name="Id_Articulo" id="Id_Articulo" value="@v.Articulo.Id" />
</td>
<td>
@Html.DisplayFor(m => v.Articulo.Nombre)
</td>
<td>
@Html.DisplayFor(m => v.Precio)
</td>
</tr>
}
</table>
but i only get one data
How should I receive the data so that it comes complete or to receive the three elements that are shown in the ajax or what am I doing wrong when sending it?
Note: I already tried with int[] Id_Articulo
, List<int>Id_Articulo
but the same thing comes out
If you have several inputs with the same id you must define another type of selector, the common thing is to use the
class
then you would use
as you will see you iterate through the items performing a
push()
in the array, so if you define aList<int>
as a parameter of the action