标签:for system 解析json tostring ajax foreach post http type
本文链接:https://blog.csdn.net/qq_22103321/article/details/78015920
前端提交json数据
$.ajax({
type: "post",
url: url,//请求地址
data: JSON.stringify(data),//json数据,如{"key1":"value1","key2":"value2"}
dataType: "json",
beforeSend: function (XMLHttpRequest) {
//请求前业务
},
success: function (data, textStatus) {
//请求成功业务
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//请求错误业务
}
});
服务端解析json
引入类
using System.IO;
using System.Web.Script.Serialization;
context.Response.ContentType = "application/json";
var data = context.Request;
var sr = new StreamReader(data.InputStream);
var stream = sr.ReadToEnd();
var javaScriptSerializer = new JavaScriptSerializer();
var jarr = javaScriptSerializer.Deserialize<Dictionary<string, object>>(stream);
string sValue = "";
foreach (var j in jarr)
{
sValue += j.Value.ToString() + ",";
————————————————
版权声明:本文为CSDN博主「Mick_小马哥」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_22103321/article/details/78015920
标签:for system 解析json tostring ajax foreach post http type
原文地址:https://www.cnblogs.com/dongjh/p/11491343.html