【发布时间】:2016-06-01 23:34:15
【问题描述】:
我正在尝试通过 AJAX 将一些数据发布到 VB.NET WebMethod。
JSON.stringify(myRows) 包含:
{
"myRows":[
{
"UniqueId":"188",
"Description":"hello",
"ClientId":"321",
"SecretKey":"dftete",
"Active":"checked",
"Delete":"delete icon"
},
{
"UniqueId":"191",
"Description":"sfsss",
"ClientId":"fsdfs",
"SecretKey":"cvvcvb",
"Active":"unchecked",
"Delete":"delete icon"
},
{
"UniqueId":"201",
"Description":"I am test singh",
"ClientId":"23424242",
"SecretKey":";kfddgdfl;ghf",
"Active":"unchecked",
"Delete":"delete icon"
},
{
"UniqueId":"202",
"Description":"Yay mai ban ne wala hun",
"ClientId":"n.csdvnsssl",
"SecretKey":"nj.ssdnfvel,vgd",
"Active":"unchecked",
"Delete":"delete icon"
}
]
}
我的 AJAX 调用是:
$.ajax({
type: "POST",
url: "MyWebServiceUtilities.asmx/savesocialloginkeys",
data: JSON.stringify(myRows),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
//some code here
},
failure: function (response) {
//some code here
},
error: function (response) {
//some code here
}
});
服务器端web方法是这样的:
<WebMethod()> _
Public Function savesocialloginkeys(ByVal myrows As String) As String
Dim response As String = ""
'------------Some code here-------------------------------
'------------Response will be based on results as per code-------
Return response
End Function
当我尝试调试时,AJAX 调用显示错误!
【问题讨论】:
-
contentType是您要发送的数据类型,在这种情况下您应该有:contentType: "charset=UTF-8"check stackoverflow.com/questions/18701282/… -
欢迎来到 StackOverflow!您应该始终发布您在调试时看到的任何错误,以便其他人可以了解发生了什么问题。
标签: jquery json ajax vb.net webmethod