I am trying to set up a simple service that accepts a string and returns a string. I have the ASP.net code built and working with it's built in test page, but cant seem to call the service from jquery.
ASP:
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="https://domain/decode")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Decode
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function Decode(Image64 As String) As String
Dim Code As String = "test"
Return Code
End Function
End Class
Then I am trying to call this service from jquery on an existing php page:
<script src="js/jquery-1.9.1.js"></script>
<script language="javascript" type="text/javascript">
$(function() {
$.ajax({
type: "POST",
url: "https://domain/decode/decode.asmx/Decode",
data: {Image64: ""},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
});
function OnSuccess(data, status)
{
alert(data.d);
}
function OnError(request, status, error)
{
alert(request.statusText);
}
I have tried changing the data format data: "{}"
etc and I keep getting "Internal Server Error" back.
I assume something might be wrong on the ASP side as I am completely new to that, but cant figure out what...
Well, not working with native, but found a great SOAP plugin: https://github.com/doedje/jquery.soap
Now its working fine =)