asp.net ajax Implementation (-): Jquery+json

Source: Internet
Author: User

For lightweight applications, the client serializes and deserializes available JSON-json.parse () and json.stringify (),

But when the server-side serialization and deserialization, I encountered some problems, I took three ways, three ways to serialize and deserialize different ways, the comparison please click here to see.

Here's the code for my operation:

Front desk:

1<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
234 <title> Untitled Page </title>
5 <script type= "Text/javascript" src= ". /js/jquery-1.3.min.js "></script>
6 <script type= "Text/javascript" src= ". /js/json2.js "></script>
7 <script type= "Text/javascript" >
8 function GetValue ()
9 {
$.get ("Process.aspx", {Action: "get"}, function (data, textstatus) {
One var name=$ ("#TName") [0];
var address=$ ("#TAddress") [0];
var age=$ ("#TAge") [0];
var obj=json.parse (data);
Name.value=obj. Name;
Address.value=obj. address;
Age.value=obj. Age;
18});
19}
20
function SetValue ()
22 {
var person=new person ($ ("#TName") [0].value,$ ("#TAddress") [0].value,$ ("#TAge") [0].value];
var str=json.stringify (person);
alert (str);
$.post ("Process.aspx", {Action: "Post", Jsonstr: "" + str + "}, function (data, textstatus) {
Alert ("Send Success");
28});
29}
30
-Function person (name,address)
32 {
this. Name=name;
this. address=address;
35}
</script>
3738<body>
<form id= "Form1" runat= "Server" >
<div>
<table>
<tr>
<td> name:</td>
<td><input type= "text" id= "Tname"/></td>
</tr>
<tr>
<td> Address:</td>
<td><input type= "text" id= "taddress"/></td>
</tr>
M <tr>
Wuyi <td> Age:</td>
<td><input type= "text" id= "Tage"/></td>
</tr>
</table>
<table>
<tr>
<td><input type= "button" onclick= "GetValue ();" value= "Load data ></td>
<td><input type= "button" value= "Update Data" onclick= "SetValue ()" ></td>
</tr>
</table>
</div>
</form>
63</body>
64

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.