ajax向webapi提交Dictionary
Script:
var data = { "a": 1, "b": 2, "c": "hello", };
$.ajax({
url: "/api/Test/Post",
type: "post",
contentType: "application/json",
data: JSON.stringify(data),
success: function (m) {
console.log(m);
}
});
Webapi
public class TestController : ApiController
{
// POST api/<controller>
[HttpPost]
public string Post(Dictionary<string,object> dict)
{
return "123";
}
}
结果: