using System.Runtime.Serialization.Json;

using System.IO;

using System.Text;

//序列化
        public string MySerialize(object o)
        {
            //序列化
            DataContractJsonSerializer json = new DataContractJsonSerializer(o.GetType());
            using (MemoryStream stream = new MemoryStream())
            {
                json.WriteObject(stream, o);
                string JsonData = Encoding.UTF8.GetString(stream.ToArray());
                return JsonData;
            }
        }

$.ajax({
            type: "GET",
            url: "../product/GetProductList",
            data: {active:1},
            dataType: "json",
            success: function (data) {
                ProductList=data;
                var html = '';
                if (data != "") {
                    for (var i = 0; i < data.length; i++) {
                        html += "<tr>";
                        html += '<td style="font-size:18px;"><a onclick="ShowProductDetails('+data[i].FoodID+')">'+data[i].FoodName+'</a></td>'
                        html += "<td>约 " + data[i].Specifications + "</td>"
                        html += "<td style='text-align:center'>" + data[i].Price + "</td>"
                        html += '<td><label class="checkbox-inline"><input id="'+data[i].FoodID+'" type="checkbox" onclick="CheckboxClick('+data[i].FoodID+')" value="" style="zoom:300%; float:right;margin-top:-1px;margin-left:-6px;"></label></td>'
                        html += "</tr>";
                    }
                    $("#ProductList").empty();
                    $("#ProductList").html(html);
                }
            }
        });

using System.IO;

using System.Web.Script.Serialization;

//反序列化
        public List<T> MyDeserialize<T>(HttpRequestBase request)
        {
            var sr = new StreamReader(Request.InputStream);
            var stream = sr.ReadToEnd();
            //反序列化
            JavaScriptSerializer js = new JavaScriptSerializer();
            var List = js.Deserialize<List<T>>(stream);
            return List;
        }

$.ajax({
                type: "POST",
                url: "../order/Pay",
                data:JSON.stringify(Orders),
                dataType: "json",
                success: function (data) {
                    if (data != "") {
                        if(data.Code==200)
                        {
                            if(hb)
                            {
                                window.location.href = '../order/status?NO='+data.NO;
                            }
                            else
                            {
                                window.location.href = '../order/status?hb=false&NO='+data.NO;
                            }
                        }
                    }
                },
                error: function () {
                    alert("网络异常,请稍后再试···");
                }
            });

最新文章

  1. node.js如何处理请求的路由
  2. proteus 运行出错,用户名不可使用中文!
  3. 快速搭建Redis缓存数据库
  4. jQuery -&amp;gt; 获取各种滤芯(filter)
  5. Windows 下安装 Oracle 12c 教程
  6. DDS视图&amp;Button控件
  7. Cocos2d中update与fixedUpdate的区别(三)
  8. POJ1006: 中国剩余定理的完美演绎
  9. redis的LRU算法(一)
  10. spring boot监控--actuator
  11. Sqlserver 命令行方式修改 用户密码的方法
  12. 2018即将过去,立个flag
  13. cocos2d-x JS 利用重复动作实现动画播放(实现倒计时)
  14. Python高阶函数_map/reduce/filter函数
  15. VS2015 C#的单元测试
  16. 【LOJ】#2230. 「BJOI2014」大融合
  17. Pandas常用命令
  18. git 代码冲突处理
  19. November 27th 2016 Week 48th Sunday
  20. (C++)UrlEncode的标准实现

热门文章

  1. (导航页)OpenStack-M版-双节点手工搭建-附B站视频
  2. static inline和inline的区别——stm32实测
  3. R-FCN:
  4. C++中整型变量的存储大小和范围
  5. 支持TV远程控制的WIN10PEX64_17763网络版by双心
  6. vue_02day练习
  7. Python3.6 SyntaxError: &#39;ascii&#39; codec can&#39;t decode byte 0xe5 in position 7: ordinal not in range(128)
  8. SpringBootThymeleaf案例
  9. C语言I作业12—学期总结
  10. 热情组——项目冲刺 Day5