2
var post = { "ID":1 };
var step = [1,2,3,4,5];
post.step = step;
console.log(post)
$.ajax({
url:'rss/test',
type:'POST',
data:post
})
public JsonResult Test(int ID, IEnumerable<string> step)
{
return Json(true);
}
我想通過JSON將它張貼,我該怎麼辦呢?當我試圖做到這一點時,我發現這不起作用。步驟都沒有工作(或郵寄)
更新:設置它後
var post = {
"ID":1,
step:[{'Name':'first'},{'Name':'second'}]
}
$.post("/rss/test",post,function(){
});
public JsonResult Test(int ID, IEnumerable<string> step)
{
return Json(true);
}
我覺得這是工作,但我在即時窗口中有導致
step
Count = 2
[0]: null
[1]: null
。
所以我希望我走在正確的方向,但兩件事都是空的。現在有人可以幫助我讓他們工作。
感謝
傳遞作爲JS對象是綁定到行動的參數性能。你的方法也會起作用:) –