【发布时间】:2014-05-07 11:19:27
【问题描述】:
我正在尝试将一些数据参数从 ajax 调用传递给 webmethod。但它不会将它们传递给 webmethod。以下是代码
function databind(query,tbl,para,spname,cmdtype){
$.ajax({
type: "POST",
url: "editviewposition.aspx/threeDTable",
data: "{query':'"+query+"','tbl':'"+tbl+"','para':'"+para+"','spname':'"+spname+"','cmdtype':'"+cmdtype+"'}", // here is the problem
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response);
},
error: function (response) {
alert(response);
}
});
}
网络方法
<WebMethod()> _
<ScriptMethod()> _
Public Shared Function threeDTable(ByVal query As String, ByVal tbl As String, ByVal para() As Object, ByVal spname As String, ByVal cmdtype As String) As Object()()()
'code
End Function
【问题讨论】:
-
我更喜欢
data: JSON.stringify({query:query,tbl:tbl,para:para,spname:spname,cmdtype:cmdtype})而不是字符串连接。您的版本的问题是您之前在 sn-p{ query中错过了引号 -
thanks.give 它作为解决方案。我会将其标记为解决方案
标签: jquery asp.net ajax web-services