I need to call a web service from Ajax
The script is as follow:
var sentData = { data: JSON.stringify(ChangedObjects) }
$.ajax({
url: '<%=ResolveUrl("ws.aspx/SaveData") %>',
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: JSON.stringify(sentData),
success: function (data, textStatus, xhr) {
console.log("Saved Successefully");
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
The value I am passing is this:
[{"id":"61","order":19},{"id":"59","order":16}]
This doesn't seem to work as the AJAX never reaches the service. I guess it is the SaveData parameter format but I can't figure out what is the right way.
Any idea ?
Public Class Fotos
Private _numero As Integer
Public Property id As Integer
Get
Return _numero
End Get
Set(ByVal value As Integer)
_numero = value
End Set
End Property
Private _orden As Integer
Public Property orden As Integer
Get
Return _orden
End Get
Set(ByVal value As Integer)
_orden = value
End Set
End Property
End Class
<WebMethod()>
Public Shared Function SaveData(ByVal sData As Fotos()) As Boolean
Dim sql As String = ""
For Each foto In sData
Dim id = foto.id
Dim order = foto.orden
Next
......
End Function