.net mvc ajax 传递多个对象的方法

前端之家收集整理的这篇文章主要介绍了.net mvc ajax 传递多个对象的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

.net mvc ajax 传递多个对象的方法


参考资料 http://www.cnblogs.com/wubh/p/6253358.html

http://blog.csdn.net/zengweiqiang/article/details/7354006

$.ajax({

type: "post",
url: "/Test/testST",
data: JSON.stringify({
model: {
user: "sfds",
password:"66655tttt"
},
testobj: {
name1: "111111",
name2: "2222222"
}

}
),
contentType: 'application/json',
async: true,
success: function (result) {
alert(result);
}


});

.net后台获取 json数据

public static string getRequestPayload(HttpRequestBase Request)
{
Stream stream = Request.GetBufferedInputStream();

StreamReader sr = new StreamReader(stream);

return sr.ReadToEnd();


}

调用方法前不能使用request对象读取数据,否则会报错

//--------------------------------------------- var obj1 = {}; obj1["model.user"] = "66666666"; obj1["model.password"] = "123456"; obj1["testobj.name1"] = "name1"; obj1["testobj.name2"] = "name2"; $.ajax({ type: "post",url: "/Test/testST",data: obj1,async: true,success: function (result) { alert(result); } }); 原文链接:https://www.f2er.com/ajax/161333.html

猜你在找的Ajax相关文章