-1
我的模型:Ajax调用发送空值到控制器
public class Hello
{
public List<string> name;
public List<string> phone;
public List<string> contact;
}
我的控制器代码
public ActionResult Home(Hello obj) // obj is coming out to be null
{
}
我的剧本是
var names =[];
var phones =[];
var contacts = [];
// some code to fill the arrays
var obj = [{
name: names,
phone: phones,
contact: contacts,
}];
debugger;
$.ajax({
cache: false,
url: 'Home',
data: { obj:obj },
success: function (data) {
var response = JSON.parse(data);
window.location = 'Download?fileGuid=' + response.FileGuid
+ '&filename=' + response.FileName;
}
})
我可以在数据调试器看到存储在数组中,但是当我将数据发送到控制器时,obj为空可以有人建议我在哪里出错?
对象的值,直到来了为空 –
你可以在这里粘贴你的代码,这样我可以给你更好的解决方案 –