0
Hello, I’m in need of a little help with ajax, I think it’s silly but I’m having a lot of difficulty and I found nothing related on the internet about it, I need to pass parameter ajax to my controller, however of type float, I created a json object to try to be able to receive the value type float, however neither with object nor with explicit value I can pass type float, only string and type int.
It follows below my function Ajax, where I create an object and send values, vlTotalLiquido, vlUnitario, are values of type float because it is money, but in that part disregard why jquery is not a typed language but the value is right as I wish to send, EXAMPLE: 2,00
var Objeto = new Object();
Objeto.idProduto = idProduto;
Objeto.IdPreVenda = parseInt($("#idPreVenda").val());
Objeto.qtItem = parseInt($("#qtItem").val());
Objeto.vlUnitario = parseFloat($("#vlUnitario").val());
Objeto.prDesconto = parseFloat($("#prDesconto").val());
Objeto.vlTotalLiquido = parseFloat($("#ValorComDesconto").val());
$.ajax(
{
url: "/ItPreVenda/SalvarItens",
dataType: "json",
type: "POST",
data: Objeto,
success: function (data) {
if (data.Resultado > 0)
alert('sucesso');
ListarItens(idprevenda);
}
});
Below follows the code of my controller, I am receiving in my Object all values type INT but the values type float cannot receive!
[HttpPost]
public ActionResult SalvarItens(ItPreVenda Objeto)
{
//ainda irei tratar os valores
return Json(Objeto);
}
In case anyone knows a way to do so Thank you and a happy new year to all!
Why don’t you take the
parseFloatand send strings to the server? When do you have2,00in type Number this will be just2.– Sergio
And I think you should take a look here: http://answall.com/q/11018/129
– Sergio