5
Widziałem wiele problemów na ten temat, ale nigdy tego. Mogę wywołać tę usługę internetową z okna przeglądarki, ale dostaję błąd z AJAX. Otrzymuję wyjątek błędu serwera wewnętrznego (500). Być może będzie musiał coś zrobić z moim adresem URL w JQuery, ponieważ łączę się z localhost. Oto (wersja uproszczona) moich WS:JQuery - usługi sieciowe ASP.NET (.asmx) - wewnętrzny błąd serwera (500)
<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
I tu jest moje 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);
Dziękujemy!
Spróbuj z 'static' kluczowego' statycznego funkcję publiczną (...) '. –
@DKM Nie ... Brak funkcji statycznych dla klas usług internetowych. – lucafik
Jeśli masz błąd "500", domyślam się, że problem leży po twojej stronie serwera. – anmarti