无法获取控制器中的所有ajax参数 [英] Unable to get all ajax parameter in controller
本文介绍了无法获取控制器中的所有ajax参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建对控制器的ajax调用时仅获取第二个参数。
When creating ajax call to controller getting 2nd parameter only.
return $http({
method: "post",
url: "/myform/AddEmployee",
data: '{ "EmpDetail":' + JSON.stringify(employee) + ', "File_ID":' + File_ID + '}',
//data: JSON.stringify(employee,File_ID),
dataType: "json"
})
控制器: -
Controller:-
public string AddEmployee(EmpDetail Emp, int? File_ID)
{
....
}
我试过的:
数据:JSON.stringify(employee,File_ID)
使用此功能后只获取第一个参数。
What I have tried:
data: JSON.stringify(employee,File_ID)
after using this getting first parameter only.
推荐答案
http({
method: post,
url: / myform / AddEmployee,
data:' {EmpDetail:' + JSON .stringify(employee)+ ' ,File_ID:' + File_ID + ' }',
// data:JSON.stringify(employee,File_ID),
dataType: json
})
http({ method: "post", url: "/myform/AddEmployee", data: '{ "EmpDetail":' + JSON.stringify(employee) + ', "File_ID":' + File_ID + '}', //data: JSON.stringify(employee,File_ID), dataType: "json" })
控制器: -
Controller:-
public string AddEmployee(EmpDetail Emp, int? File_ID)
{
....
}
我试过的:
数据:JSON.stringify(employee,File_ID)
使用此功能后只获取第一个参数。
What I have tried:
data: JSON.stringify(employee,File_ID)
after using this getting first parameter only.
我得到了解决方案。
我传递的参数名称不同。
电话应该是这样的: -
var empData = JSON.stringify({Emp: employee,File_ID:File_ID});
I got the solution.
I was passing parameters with different names.
The call should be like that:-
var empData= JSON.stringify({ Emp: employee, File_ID: File_ID });
这篇关于无法获取控制器中的所有ajax参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文