jqueryは自動的にフォームをjsonにパッケージして具体的に実現します。


フロントページ:
 
<span style="font-size:14px;"> <form action="" method="post" id="tf">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<th>

</th>
<td>
<input type="text" id="txtUserName" name="model.UserName" />
</td>
<th>

</th>
<td>
<input type="text" name="model.Mobile" id="txtMobile" maxlength="11" />
</td>
<th>

</th>
<td>
<input type="password" name="model.Pwd" id="txtPwd" maxlength="11" />
</td>
</tr>
<tr>
<td style="text-align: center;" colspan="2">
<input type="button" value=" " style="padding-top: 3px;" name="butsubmit"
id="butsubmit" />
</td>
</tr>
</table>
</form>
//
$(function () {
$("#butsubmit").click(function () {
var data = $("#tf").serializeArray(); // form json


// $.ajax({
// type: "Post", // WebService Post
// contentType: "application/json", //WebService Json
// url: "/home/ratearticle", // WebService ---- WsURL/
// data: data, // , data: "{paraName:paraValue}",
// dataType: 'json',
// success: function (result) { // ,result,
// alert(result.UserName + result.Mobile + result.Pwd);
// }
// });

$.post("/home/ratearticle", data, RateArticleSuccess, "json");
});
})



//

function RateArticleSuccess(result) {
alert(result.UserName + result.Mobile + result.Pwd);
}</span>
バックエンド処理:
 
<span style="font-size:14px;">public JsonResult ratearticle(UserInfo model)
{
return Json(model);
}</span>