Je souhaite utiliser jquery ajax dans mon projet. Je viens de lancer un simple ajax avec du code derrière. J’ai eu l’erreur d’alerte comme “erreur interne 500”
$(document).ready(function () { $.ajax({ type: "POST", url: "listprac.aspx/sayHello", contentType: "application/json; charset=utf-8", data: "{}", dataType: "json", success: AjaxSucceeded, error: AjaxFailed }); }); function AjaxSucceeded(result) { alert(result.d); } function AjaxFailed(result) { alert(result.status + ' ' + result.statusText); }
Mon code derrière:
public static ssortingng sayHello() { return "hello "; }
Pour les pages aspx
vous devrez décorer votre méthode code-behind avec l’atsortingbut [WebMethod()]
:
[WebMethod()] public static ssortingng sayHello() { return "hello "; }
Edit: WebMethod
trouve dans l’espace de noms System.Web.Services.WebService
.