js:
var obj = { 'a': "1", "b": 5 }; $.ajax({ url: "/.../...", type: "POST", async: false, data: JSON.stringify(obj), success: function (result) { alert(result); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.status); alert(XMLHttpRequest.readyState); alert(textStatus); } });
后台:
[HttpPost] public ActionResult Test() { var sr = new StreamReader(Request.InputStream); string josnStr = sr.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); object requestData = js.Deserialize<object>(josnStr); return Json(true); }