我如何发送int数组从$就到C#MVC?
解决方案 $。阿贾克斯({
网址:< URL的作用&gt ;,的
键入:POST,
数据:JSON.stringify([1,2,3]),
数据类型:JSON,
的contentType:应用/ JSON的;字符集= UTF-8
});
和在动作
公众的ActionResult ReceiveIntArray(INT []整数)
{
...
}
MVC会自动解析JSON。
检查出this问题。
How can I send int array from $.ajax to c# mvc?
解决方案$.ajax({
url: <Url of the action>,
type: "POST",
data: JSON.stringify([1,2,3]),
dataType: "json",
contentType: 'application/json; charset=utf-8'
});
and in the action.
public ActionResult ReceiveIntArray(int[] ints)
{
...
}
mvc should parse the json automatically.
check out this question.
上一篇:ASP .NET MVC 3 - 如何提交一个ajax的形式嵌套在HTML表单中嵌套、表单、形式、NET
下一篇:PHP的错误:使用ob_flush()[ref.outcontrol]:未能刷新缓冲区。没有缓冲刷新缓冲区、错误、PHP、ob_flush