jquery自動(dòng)將form表單封裝成json的具體實(shí)現(xiàn)
<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>
聯(lián)系手機(jī):
</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>
//提示到服務(wù)器
$(function () {
$("#butsubmit").click(function () {
var data = $("#tf").serializeArray(); //自動(dòng)將form表單封裝成json
// $.ajax({
// type: "Post", //訪問WebService使用Post方式請(qǐng)求
// contentType: "application/json", //WebService 會(huì)返回Json類型
// url: "/home/ratearticle", //調(diào)用WebService的地址和方法名稱組合 ---- WsURL/方法名
// data: data, //這里是要傳遞的參數(shù),格式為 data: "{paraName:paraValue}",下面將會(huì)看到
// dataType: 'json',
// success: function (result) { //回調(diào)函數(shù),result,返回值
// alert(result.UserName + result.Mobile + result.Pwd);
// }
// });
$.post("/home/ratearticle", data, RateArticleSuccess, "json");
});
})
//結(jié)果顯示
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>
- jquery實(shí)現(xiàn)ajax提交form表單的方法總結(jié)
- jQuery-serialize()輸出序列化form表單值的方法
- jQuery實(shí)現(xiàn)form表單基于ajax無(wú)刷新提交方法詳解
- jquery序列化form表單使用ajax提交后處理返回的json數(shù)據(jù)
- jquery的ajax提交form表單的兩種方法小結(jié)(推薦)
- jQuery Form表單取值的方法
- jQuery模板技術(shù)和數(shù)據(jù)綁定實(shí)現(xiàn)代碼
- 一個(gè)可綁定數(shù)據(jù)源的jQuery數(shù)據(jù)表格插件
- Jquery 模板數(shù)據(jù)綁定插件的使用方法詳解
- jQuery實(shí)現(xiàn)獲取form表單內(nèi)容及綁定數(shù)據(jù)到form表單操作分析
相關(guān)文章
使用jQuery的load方法設(shè)計(jì)動(dòng)態(tài)加載及解決被加載頁(yè)面js失效問題
這篇文章主要介紹了使用jQuery的load方法設(shè)計(jì)動(dòng)態(tài)加載及解決被加載頁(yè)面js失效問題,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03jquery實(shí)現(xiàn)select選中行、列合計(jì)示例
這篇文章主要介紹了jquery如何實(shí)現(xiàn)select選中行、列合計(jì)示例 ,需要的朋友可以參考下2014-04-04jQuery實(shí)現(xiàn)的Email中的收件人效果(按del鍵刪除)
基于jquery實(shí)現(xiàn)的Email中的收件人效果,可通過del鍵刪除,需要的朋友可以參考下。2011-03-03使用jQuery快速解決input中placeholder值在ie中無(wú)法支持的問題
本篇文章主要介紹了使用jQuery快速解決input中placeholder值在ie中無(wú)法支持的問題。需要的朋友可以過來(lái)參考下,希望對(duì)大家有所幫助2014-01-01jquery實(shí)現(xiàn)輸入框動(dòng)態(tài)增減的實(shí)例代碼
主要功能是動(dòng)態(tài)增減輸入框,而且支持對(duì)各個(gè)輸入框的檢測(cè),每個(gè)輸入框在輸入內(nèi)容后,對(duì)其進(jìn)行錯(cuò)誤提示2013-07-07IE8下Jquery獲取select選中的值post到后臺(tái)報(bào)錯(cuò)問題
IE8下出現(xiàn)的問題是直接將selectedValue post發(fā)送到后臺(tái),后臺(tái)接收時(shí)會(huì)報(bào)錯(cuò),這是因?yàn)镮E8下selectedValue當(dāng)成了數(shù)組,后臺(tái)無(wú)法識(shí)別2014-07-07總結(jié)jQuery插件開發(fā)中的一些要點(diǎn)
這篇文章主要介紹了總結(jié)jQuery插件開發(fā)中的一些要點(diǎn),包括命名空間與事件events等重點(diǎn)和難點(diǎn)部分的講解,要的朋友可以參考下2016-05-05jQuery實(shí)現(xiàn)將div中滾動(dòng)條滾動(dòng)到指定位置的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)將div中滾動(dòng)條滾動(dòng)到指定位置的方法,涉及jQuery結(jié)合animate方法動(dòng)態(tài)操作頁(yè)面元素屬性的相關(guān)技巧,需要的朋友可以參考下2016-08-08