jquery JSON AJAX 如何传值,后台如何取值
{"0":"行号","1":"产品编号","2":"产品描述","3":"产品单价","4":"产品数量","5":"产品总价","6":"操作"},{"0":"行号","1":"PM1003","2":"G4567-023","3":"23.00","4":"11","5":"253.00","6":"操作"},{"0":"行号","1":"PM1002","2":"G12-13","3":"12.00","4":"1","5":"12.00","6":"操作"}
<script type="text/javascript">
$.ajax({
type: 'POST',
url: "DY_OrderFromTwo.aspx",
data: "p"+ JSON.stringify(myRows), //p是参数名,s是值
contentType: "application/json; charset=utf-8",//(可以)
success: function (msg) {
//msg是返回的结果,这里对返回值进行处理
}
});
</script>
后台如何取值, 这个 url 是本页
我试过
string s = HttpContext.Current.Request["p"].ToString();
未将对象引用到实例
------解决方案--------------------Asp.net Json 客戶端与服务端传递
------解决方案--------------------data: "p"+ JSON.stringify(myRows), //p是参数名,s是值
这里传参这是这样的,改成这样试试
data: {p:JSON.stringify(myRows)}, //p是参数名,s是值
------解决方案--------------------上次收藏了个还不错。
http://www.cnblogs.com/yeer/archive/2009/07/23/1529460.html
------解决方案--------------------data: "p"+ JSON.stringify(myRows)
是少个=号吧
data: "p="+ JSON.stringify(myRows)