简单的Json数据提交 

jQuery ajax  webservice:get 和 post

一、GET 方式
客户端
            var data = { classCode: "0001"}; // 这里要直接使用JOSN对象
            $.ajax({
                type: 
"GET",
                contentType: 
"application/json; charset=utf-8",
                url: 
"/WebServices/ProductPropertyWebService.asmx/GetProductPropertyList",
                dataType: 
"json",
                anysc: 
false,
                data: data,
                success: RenderProperties,
                error: 
function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(errorThrown 
+ ':' + textStatus);  // 错误处理
                }
            }); 

 

服务器端
     [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)] //UseHttpGet = true
        public List<Property> GetProductPropertyList()
        {
            
string classCode = HttpContext.Current.Request["classCode"]; // Get 方式,要在查询字符串里得到参数值
            return PropertyManager.GetPropertySet(classCode, "zh-CN").DataList;
        }

 

相关文章:

  • 2022-01-13
  • 2021-11-23
  • 2021-06-25
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案