我正在尝试通过stringyfing将数组发送到服务器端,但是操作后结果为空[]
。有我的代码:
let calculatePriceOfMultipleFields = (model, field, select, computable) => {
if(computable.length === 0){
return false
}
let priceArray = fillPriceArray(model, computable)
console.log(priceArray)
console.log(JSON.stringify(priceArray))
let ajaxData = {
id: select.value,
model: model,
field: field,
priceArray: priceArray
}
$.ajax({
url: "/erp/currencyhandler/multiple-currency-handler/get-price-by-currency",
data: ajaxData,
success: function ( data ) {
console.log(data)
return false
}
})
}
let fillPriceArray = (model, computable) => {
let price = []
computable.forEach((name) => {
let id = model.toLowerCase()+"-"+name
let input = document.getElementById(id)
price[id] = input.value
})
return price
}
我从console.log
得到的是:
[crmorder-amount: "6.22", crmorder-delivery_price: "5", crmorder-discount_percentage: "15", crmorder-total_amount: "10.29"]
在第一个填充数组的位置,第二个简单地为[]
。
我的弦乐舞怎么了?我的错在哪里?谢谢!