This is what I do. Hope this helps:
var WebServiceUrl = 'SomeWebservice.asmx/SomeMethod';
var DataToSend = new Object();
DataToSend = {
FirstName : 'John',
LastName : 'Smith'
};
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: WebServiceUrl,
data: JSON.stringify(DataToSend),
dataType: "json",
success: function (msg) {
alert('Success');
},
error: function (err){
alert('Error');
}
});
And suppose you have a web service. I have a simple ASP.NET VB web service: SomeWebservice.asmx and its method signature as follows:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function SomeMethod(ByVal FirstName As String, ByVal LastName As String) As String
source
share