5
이 주제에 대해 많은 문제점을 보았지만이 문제는 결코 발생하지 않았습니다. 브라우저 창에서이 웹 서비스를 호출 할 수 있지만 AJAX에서 오류가 발생합니다. 내부 서버 오류 예외 (500) 가져 오는 중입니다. 내가 JQuery에서 내 URL로 뭔가를해야 할 수도있다.JQuery - ASP.NET 웹 서비스 (.asmx) - 내부 서버 오류 (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
그리고 여기에 내 JS입니다 : 여기 내 WS의 (단순화 된 버전)입니다
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);
감사합니다!
는'static' 키워드'공공 정적 기능 (...)'와보십시오. –
@DKM 아니요 ... 웹 서비스 클래스에는 정적 함수가 허용되지 않습니다. – lucafik
'500' 오류가 발생하면 서버 측에 문제가 있다고 생각합니다. – anmarti