I saw many problems on this topic, but never this one. I am able to call this web service from browser window, but I get the error from AJAX. I am getting Internal Server Error Exception (500). It might have to do something with my URL in JQuery, since Im connecting from localhost. Here is (a simplified version) of my WS:
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/webdienst/_default")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class _default
Inherits System.Web.Services.WebService
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.JSON)> _
Public Function getOrganizerEventsJSON(ByVal strUser As String, ByVal strPasswort As String) As TEvent
Dim t As TEvent
'I get the event for the specified username and password
Return t
End Function
End Class
And here is my JS:
var ASMX = "http://localhost:56035/default.asmx/";
jQuery.callAsmx = function (method, data, onSuccess, onError) {
var url = ASMX + method;
return $.ajax({
type: "POST",
url: url,
data: $.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (typeof onSuccess == "function") {
onSuccess(response.d);
}
},
error: function (msg) {
if (msg.status != 0) {
if (typeof onGlobalError == "function") {
onGlobalError([msg],
"Error while calling " + url, ERRORTYPE.error);
}
if (typeof onError == "function") {
onError(msg);
}
}
}
});
};
$.callAsmx("GetOrganizerEventsJSON", { strUser: username, strPasswort: password }, onEventsLoaded);
Thank you!
I have Same error and can solved it :
you should remove below lines :
contentType: "application/json; charset=utf-8",
dataType: "json",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With