i have this script
in my sight
$(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(?????);
},
});
});
});
public JsonResult PreciosPorTipoVenta(int Id_Plan, int Id_Articulo)
{
return Json(querty, JsonRequestBehavior.AllowGet);
}
and I have this input to which I want to assign the value that the controller returns from ajax
<input type="text" id="Precio" name="Precio" />
what should I put there because I already tried to put precios.Value
as I had seen in an example but nothing comes out
You need to go through the json returned, in this case you catch it as price, you have to go through the json price depending on the attributes that it has and that you want to show in the example input:
oscar 's answer should be valid since you get a
json
this way{precios:[{precio:600}]}
.Try
$('#Precio').val(precios[0].precio);
as it is possible that you are getting an array with more data