我的控制器从JSON接收值时出现问题 [英] Problems when my controler receive values from JSON
本文介绍了我的控制器从JSON接收值时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个5位的数组,所有这些都具有相同的值170.881.914(没有Decimals),当我通过Firefox调试时值是可以的,但是当这些数据来到我的控制器时类型为List< float>,值由170.881.920重新计算,我不知道为什么。
这是代码。
var actualizarFilaItem = JSON.stringify({
idProyecto:idProyecto,
item:itemGuardar,//这里是数组
año:añoActual
var urlActualizarFilaItem = $('#urlActualizarFilaItem')。val();
$ .ajax({
url:urlActualizarFilaItem,
类型:'POST',
数据:actualizarFilaItem,
async:false,
cache:false,
dataType:'json',
contentType:application / json; charset = utf-8,
beforeSend:function(){
showSpinner();
},
我尝试过:
我试图将出现值的所有地方转换为parseFloat
解决方案
('#urlActualizarFilaItem')。val();
.ajax({
url:urlActualizarFilaItem,
type:'POST',
data:actualizarFilaItem,
async:false,
cache:false,
dataType:'json',
contentType:application / json; charset = utf-8,
beforeSend:function(){
showSpinner();
},
什么我试过了:
我试图将所有出现值的地方转换为parseFloat
I have an array with 5 position and all these with the same value 170.881.914 (without Decimals), when I debug by Firefox the values are ok, but when these come to my controller with type List<float>, the values were remplaced by 170.881.920 and I don't know why.
this is the code.
var actualizarFilaItem = JSON.stringify({ "idProyecto": idProyecto, "item": itemGuardar, //Here go the array "año": añoActual
var urlActualizarFilaItem = $('#urlActualizarFilaItem').val(); $.ajax({ url: urlActualizarFilaItem, type: 'POST', data: actualizarFilaItem, async: false, cache: false, dataType: 'json', contentType: "application/json; charset=utf-8", beforeSend: function () { showSpinner(); },
What I have tried:
I tried to convert in all the places where appear the value to "parseFloat"
解决方案
('#urlActualizarFilaItem').val();
.ajax({ url: urlActualizarFilaItem, type: 'POST', data: actualizarFilaItem, async: false, cache: false, dataType: 'json', contentType: "application/json; charset=utf-8", beforeSend: function () { showSpinner(); },
What I have tried:
I tried to convert in all the places where appear the value to "parseFloat"
这篇关于我的控制器从JSON接收值时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文