Front page:
Copy Code code as follows:
<span style= "FONT-SIZE:14PX;" > <form action= "" method= "Post" id= "TF" >
<table width= "100%" cellspacing= "0" cellpadding= "0" border= "0" >
<tr>
<th>
Name:
</th>
<td>
<input type= "text" id= "txtUserName" "name=" model. UserName "/>
</td>
<th>
Contact Mobile:
</th>
<td>
<input type= "text" name= "model. Mobile "id=" Txtmobile "maxlength="/>
</td>
<th>
Password:
</th>
<td>
<input type= "password" name= "model." Pwd "id=" txtpwd "maxlength="/>
</td>
</tr>
<tr>
<TD style= "Text-align:center" colspan= "2" >
<input type= "button" value= "submitted" style= "PADDING-TOP:3PX;" Name= "Butsubmit"
Id= "Butsubmit"/>
</td>
</tr>
</table>
</form>
Prompt to Server
$ (function () {
$ ("#butsubmit"). Click (function () {
var data = $ ("#tf"). Serializearray (); Automatically encapsulate form forms into JSON
$.ajax ({
Type: "POST",//Access WebService use POST method request
ContentType: "Application/json",//webservice returns JSON type
URL: "/home/ratearticle",//Calling WebService address and method name combination----Wsurl/Method name
Data:data,//Here is the parameter to pass, the format is data: "{Paraname:paravalue}", the following will see
DataType: ' JSON ',
Success:function (Result) {//callback function, result, return value
Alert (result. UserName + result. Mobile + result. PWD);
// }
// });
$.post ("/home/ratearticle", Data, Ratearticlesuccess, "json");
});
})
Results show
function ratearticlesuccess (Result) {
Alert (result. UserName + result. Mobile + result. PWD);
}</span>
Back-end Processing:
Copy Code code as follows:
<span style= "FONT-SIZE:14PX;" >public Jsonresult ratearticle (UserInfo model)
{
return Json (model);
}</span>