Così ti funziona?
codice:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
<System.Web.Services.WebMethod()>
Public Shared Function GetData() As String
Return "Ciao"
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../js/jquery/jquery-min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
// <![CDATA[
function Button1_onclick()
{
$.ajax({
type: "POST",
url: "prova.aspx/GetData",
data: '{}',
async: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response.d);
},
error: function () {
alert("fail");
}
});
}
// ]]>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>PROVA</h1>
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</div>
</form>
</body>
</html>