发送数组到控制器 [英] Send array to the controller
本文介绍了发送数组到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将阵列发送到控制器?我是这样尝试的:
How can i send array to the controller? I tried so:
window.location.href = "/SomeController/SomeMethod?fields=" + SomeArray;
等等:
window.location.href = "/SomeController/SomeMethod?fields[][]=" + SomeArray;
在控制器中,我这样收到:
In controller i recieve so:
public ActionResult SomeMethod(int[][] fields) // here fields = null;
{
// Some code
}
推荐答案
如果您使用的是jQuery,请尝试 jQuery.param
If you are using jQuery, try jQuery.param
var data ={
fields :[
[
'car',
'bike'
]
]
};
window.location.href = 'SomeController/SomeMethod?'
+ decodeURIComponent( $.param(data) );
这篇关于发送数组到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文