通过ajax帖子上的“数据”属性,我想向action方法发送参数。参数对象中的所有值都将通过,十进制/双精度值除外。为什么会这样,我该怎么办?
我试图将值更改为string甚至int。它可以通过,但是以小数或双精度通过是很重要的。
mapHub.client.requestForHelpInClient = function (requestDetails) {
$.ajax({
type: "POST",url: '@Url.action("RequestPartialView","Supplier")',data: requestDetails,success: function (response) {
$("#Request").html(response);
},error: function (error) {
console.log(error);
}
});
}
[HttpPost]
public actionResult RequestPartialView(RequestDetails reqDetails)
{
RequestViewModel reqVm = new RequestViewModel() { requestDetails = reqDetails };
return PartialView("RequestPartialView",reqVm);
}
///这是我传递给执行ajax调用的requestForHelpInClient函数的对象
public class RequestDetails
{
public int CustomerId { get; set; }
public Customer Customer { get; set; }
public int NumberOfHours { get; set; }
public string TypeOfmachine { get; set; }
public List<Supplier> NearestSupplierList { get; set; }
}
public class Customer : MapClient
{
public int CustomerID { get; set; }
public string AspNetUserID { get; set; }
public string Name { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
}
除经度和纬度十进制值外,所有值都从ajax调用传递到action方法参数。
我没有收到任何错误消息。该值仅表示“ 0”