私はVB.NET WebMethodにAJAX経由でデータをPOSTしようとしています。WebMethodにJSONデータを送信
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 http://stackoverflow.com/questions/18701282/what -is-content-type-and-ajax-request- – CMedina
ようこそStackOverflowへ!デバッグ時に表示されるエラーを常に投稿して、間違っていることを理解できるようにしてください。 –