public ActionResult DoSomething(string[] arr, bool someBool, int someInt) { }
提交陣列PARAM與jQuery AJAX /負載
試圖從jQuery的調用上述方法:
var test = [];
test.push('dog');
test.push('cat');
$container.load('MyController/DoSomething',
{ 'arr[]': test, 'someBool': true, 'someInt': 1 },
function(response, status, xhr) {
// ...
});
陣列paramater爲空,其他PARAMS都很好。我究竟做錯了什麼?
Chrome開發者工具顯示錶單數據被提交爲
arr%5B%5D%5B%5D:dog
arr%5B%5D%5B%5D:cat
someBool:true
someInt:1
不知道什麼在那裏發生的,但不正確的看向我
就是這樣。我之前實際遇到過這個問題,但卻忘記了,直到這個答案慢慢地記住了我的記憶。 – fearofawhackplanet 2010-10-15 13:33:50
感謝使用'load'而不是'ajax'的例子。 – 2012-04-02 13:22:09
同樣的問題發生在Java Struts2上,這個修復對Struts2也有好處 – 2014-07-14 19:14:54