asp.net下js通过AJAX调用后台函数传参数出错
乐乐猪 2016-03-15 10:31:59 function SelectRow(Index) {
var i = Index + 1;
var gdview3 = document.getElementById("<%=gridview3.ClientID %>");
var tid = document.getElementById("<%=lbsyh0.ClientID%>").innerText;
var axt = document.getElementById("<%=lbzzs.ClientID%>").innerText;
var vet = document.getElementById("<%=lbzls.ClientID%>").innerText;
var inthtzx = gdview3.rows[i].cells(2).innerText;
var a = i - (inthtzx - 1);
var lx = gdview3.rows[a].cells(1).innerText;
var dass = '{strtrain_id:"' + tid + '",straxle_total:"' + axt + '",strvehicle_total:"' + vet + '",inthtzx:"' + inthtzx + '",inthtlx:"' + lx + '"}';
$.ajax({
type: "POST",
url: "ht.aspx/gettmqxzb",
// data: "{ 'strtrain_id': 'tid', 'straxle_total': 'axt', 'strvehicle_total': 'vet', 'inthtzx': 'inthtzx', 'inthtlx': 'lx' }",
data: dass,
contentType: "application/json;charset=utf-8",
dataType: "text",
success: function (data) {
alert(data.d);
},
error: function (err) {
alert(err);
}
});
}
返回的错误是object object
如果不传参数 后台函数就能运行 所以感觉是data的格式或方法有问题
后台函数
<WebMethod()>
Public Shared Function gettmqxzb(strtrain_id As String, straxle_total As String, strvehicle_total As String, inthtzx As String, inthtlx As String) As String
Return "xxxxxxxxx"
End Function