没时间,简单粗暴,直接上代码。
前端(aspx文件中):
$.ajax({
type: "POST",
contentType: "application/json",
url: "Aaaaa.aspx/ShenPiPass",
data: JSON.stringify({
orderId: 1,
shenpiMsg: "sdfasdfasdfasd"
}),
timeout: 50000,
dataType: 'json', //WebService 会返回Json类型
success: function (result) { //回调函数,result,返回值
debugger;
if (result.d == "success") { //他娘的为什么要是.d,我也不知道
layer.alert(result);
}
}
});
要点: contentType
, JSON.stringify
,以及莫名其妙的.d
后端对应的Aaaaa.aspx.cs
文件
[WebMethod]
public static string ShenPiPass(int orderId, string shenpiMsg)
{
//*****
return "success";
}
要点:[WebMethod]
、static
、参数写法