ciao a tutti,
in una pagina .aspx ho questo script js semplice semplice (un test)
Codice PHP:
$(function () { $.ajax({ type: "POST", url: "Crud.aspx/GetData", data: '{}', async: false, contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { alert(response.d); }, error: function () { alert("Errore"); } }); });
lato server nel CodeBehind della pagina ho la function shared GetData che restituisce una stringa:
Public Shared Function GetData() As String
Return "Ciao"
End Function
la funzione vine chiamata sul mio evento e non va in errore ma alert(response,d) mi da sempre undefined
se guardo nella finestra di output di visual studio ho un errore 401 (sembrerebbe errore di autorizzazione)
..."success":true,"responseCode":"401","url":"http ://localhost:56128/Crud.aspx/GetData","httpMethod":"POST","properties":{"Develo perMode":"true"}}}}
ho provato anche a mettere nella funzione vb la direttiva
<System.Web.Services.WebMethod()>
ma non riesco a vedere l'alert della stringa ciao
Qualcuno + esperto sa dirmi come risolvere?
Grazie