I'm struggling to figure out why I keep getting an Internal Server Error when trying to call a web service in my HTML page using JavaScript and Ajax. Here is the error message:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Here is the Ajax code snippet:
function Image() {
$.ajax({
type: "POST",
url: "WebService.asmx/GetImage",
data: "{'sDB': '" + "sDB" + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnGetMemberSuccess,
failure: function (errMsg) {
$('#errorMessage').text(errMsg);
}
});
function OnGetMemberSuccess(data, status) {
alert("data" + data.d);
$("#MemberDetails").html(data.d);
$('input[type=button]').attr('disabled', false);
}
}
The issue seems to be with the sDB variable being Null.
The button click code looks like this:
<input type="button" id="Button" value="Image" onclick="Image()" />
It's worth noting that this same code has worked before in other projects without any issues.
And here is the web service code snippet:
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> <WebMethod()> _
Public Function GetImage()
'Code here...
End Function
End Class
The web service code appears to be functioning correctly according to my understanding. The problem likely lies within the Ajax code. Any help would be greatly appreciated. Thank you!