一、按dataType: "text"传json数据,将json数据写到{}内,后台按自定义class类接收,只写一个接收参数
$.ajax({
type: "post",
url: "/UI/Rwb_page/rwb.aspx/get_sz",
dataType: "text",
data:"{ rwb_Model : { bh:'1', rwh:'2'}}",
async: false,
traditional: true,
contentType: "application/json; charset=utf-8",
success: function (data) {
var hh = JSON.parse(data);//解析得到json数据
var jj = JSON.parse(hh.d);
if (jj[0].jg) {
alert("ok!");
}
},
error: function () {
alert("123!");
}
});
二、按dataType: "json"传json数据,将json数据写到data{}内,后台按自定义class类接收,只写一个接收参数
$.ajax({
type: "post",
url: "/UI/Rwb_page/rwb.aspx/get_sz",
dataType: "json",
data: {
bh:'1',
rwh: '2'
},
async: false,
traditional: true,
contentType: "application/json; charset=utf-8",
success: function (data) {
var hh = JSON.parse(data);//解析得到json数据
var jj = JSON.parse(hh.d);
if (jj[0].jg) {
alert("ok!");
}
},
error: function () {
alert("123!");
}
});