As @vc mentioned in the comments you'll need to make use of the ScriptMethodAttribute as well as WebMethod because you want your request to be GET and not POST so change your code as follows:
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public static string GetData()
{
return "test";
}
And in the markup you can do
function ShowTestMessage() {
$.ajax({
type: "GET",
url: "YourPage.aspx/GetData",
data: {},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
<input id="ButtonId" type="button" value="Show Message"
onclick = "ShowTestMessage()" />
Don't forget to add the following reference
using System.Web.Script.Services;
using System.Web.Services;