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);
}
I want to post it through JSON, how can I do this? When I tried to do this I found that this did not work. The step are not worked (or post)
update: after setting it to
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);
}
i feel it’s work but i got result
step
Count = 2
[0]: null
[1]: null
in immediate window.
so i hope i am go in right direction but both thing are null. now someone can help me to get them work.
thanks
The data types on the server don’t match the object’s your sending from your client. Try this.
Then in your controller
You have to check it though, didn’t compile it.
To post the data you have to set the dataType properly: