码迷,mamicode.com
首页 > Web开发 > 详细

json数据的获取(网络摘抄)

时间:2014-09-17 10:04:42      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   使用   ar   for   数据   

一个简单的对象:

$.ajax({
                    type: "post",
                    url: "Handler.ashx",
                    dataType: "html",
                    data: { uid: "437", uname: "%u6211%u884C%u5BA2%u670D" },
                    success: function (msg) {
                        alert(msg);
                    },
                    error: function () { alert(123) }
                })

可以使用 context.Request.Form["uid"]、context.Request.Form["uname"]来获取对象的两个字段。

数组:如果传递的是数组,应该传递一个count字段来确认行数

 1 $.ajax({
 2                     type: "post",
 3                     url: "Handler.ashx",
 4                     dataType: "html",
 5                     data: { count:2, 
 6                             people:[{ uid: "437", uname: "小1" },
 7                                   { uid: "123", uname: "小2"} ]
 8                           },
 9                     success: function (msg) {
10                         alert(msg);
11                     },
12                     error: function () { alert(123) }
13                 })

可用context.Request.Form["people[0][uid]"],context.Request.Form["people[0][uname]"]获取

1 var param = { insuranceName: "小小明"};
2 param.Name="小明";

可用context.Request.Form["customerParam[Name]"]或context.Request.Params["customerParam[Name]"]来获取;

json数据的获取(网络摘抄)

标签:style   blog   color   io   os   使用   ar   for   数据   

原文地址:http://www.cnblogs.com/ChenRihe/p/3976471.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!