JQuery以JSON方式提交数据到服务端

第一步:把对象转JSON字符格式

var jsonStringify = JSON.stringify({})

 第二步:POST提交

$.post("/api/notify_url.aspx", jsonStringify, function (res) {

}, "json");

 第三步:.NET后台接收数据

protected void Page_Load(object sender, EventArgs e)
{
    Response.ContentType = "application/x-www-form-urlencoded";
    StreamReader reader = new StreamReader(Request.InputStream);
    string stream = reader.ReadToEnd();
    notifyjson json = new JavaScriptSerializer().Deserialize<notifyjson>(stream);
}

 

posted @ 2018-11-26 11:18  microsoftzhcn  阅读(2013)  评论(0编辑  收藏  举报