zoukankan      html  css  js  c++  java
  • AJAX请求

    $.ajax({
      type:"post",  //请求方式
      url:"../../ZCGL/ZCGL_Handler.ashx", 
      data: {'type':'ZCGL_NGD_ISCZ','_str':_str},     //参数
      async: false,
      contentType:"application/x-www-form-urlencoded;charset=UTF-8",
      //dataType:"json",  
      

      success: function (data) {
      if(data != "False")     {        alert("成功!");     } else {       alert("失败!");     };   } });

    后台接收:

     string type=context.Request["type"].ToString();

    json:

        <script src="jquery-1.8.3.js" type="text/javascript"></script>
        <script src="json2.js" type="text/javascript"></script>
    <script type="text/javascript">  
            var user = {
                name: "张三",
                age: 25,
                weight: 135
            };
    
            $(function () {
                $.ajax({
    
                    url: "AJAX.aspx",
                    type: "post",
                    data: JSON.stringify(user),//序列化
                    headers: { Accept: "application/json", "Content-Type": "application/json" },
                    dataType: "json",
                    processData: false,
                    success: function (data, textStatus, jqXHR) {
    
                    }
                });
            }); 
    
        </script>

    后台:

    using Newtonsoft.Json;
    using System.Web.Services;
    using Newtonsoft.Json.Linq;
    StreamReader sr = new StreamReader(Request.InputStream);
                string userStr = sr.ReadToEnd();
    
                JObject jo = (JObject)JsonConvert.DeserializeObject(userStr);
    
                JArray jarry = JArray.Parse(jo["User"].ToString());
    //var modleList = JsonConvert.DeserializeObject<List<SupplierDetail>>(modle);

    网上下载文件  

    Newtonsoft.Json.Net20.dll

    json2.js

    引用  Newtonsoft.Json.Net20.dll

  • 相关阅读:
    Python多进程实现并行化随机森林
    Python多进程队列间传递对象
    Umlet和draw.io 使用心得
    简单认识Adam优化器
    使用BERT进行情感分类预测及代码实例
    【深度学习】深入理解Batch Normalization批标准化
    Vue插件总结
    Vue配置环境识别
    pc端微信上传BUG
    Vue原生订单列表
  • 原文地址:https://www.cnblogs.com/fjptwwf/p/5594412.html
Copyright © 2011-2022 走看看