Please see the attached image我无法弄清楚为什么传递给控制器的对象的所有值总是显示为null。我在这里错过了什么?在此先感谢!!
控制器
{
"query": {
"has_child": {
"type": "sometype",
"score_mode": "sum",
"query": {
"bool": {
"must": [
{
"term": {
"somefield": "somevalue"
}
},
{
"function_score": {
"script_score": {
"script": "1"
}
}
}
]
}
},
"inner_hits": {}
}
}
}
查看
[HttpPost]
public JsonResult SaveOrder(Order order, List<Item> items)
{
//do something here;
return Json("OK");
}
类
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnsave").on('click', function () {
var url = '@Url.Action("SaveOrder", "Employee")';
var data1 = { CustomerName: 'MS' };
var data2 = [{ ItemName: "Laptop", Quantity: 5 },
{ ItemName: "Desktop", Quantity : 25}];
$.ajax({
url: url,
type: "POST",
data: { order:data1, items: data2 },
datatype: "json",
ContentType: "application/json",
cache: false,
success: function (resp) {
alert('Success' + resp);
},
error: function (resp) {
alert("Something Went Wrong" + resp);
}
})
})
})
</script>