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);
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM