ASP.NET ajax c# always returns undefined
<p>I searched and tried for days now but I cant find any solution. I looked up nearly every tutorial and nearly every question on this board, but no code worked for me. (I know this is a duplicate question but since no other code worked at all, you are my last hope)</p>

<p>I'm trying to return a <code>AJAX request</code> from C# in ASP but no matter what it always returns <code>undefinded</code> even with code from tutorials.</p>

<p>Here is what I have in my <code>Default.aspx</code></p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function () {

     $.ajax({
         type: "POST",
         url: "Default.aspx/GetData",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function (response) {
             alert(response.d);
         },
         failure: function (response) {
             alert(response.d);
         }
     });
 });
&lt;/script&gt;
</code></pre>

<p>and here is my codebehind from Default.aspx.cs</p>

<pre><code>[WebMethod]
public static string GetData()
{
    return "This string is from Code behind";
}
</code></pre>

<p>The Problem is: the c# method dont activate... I dont know why and I get no errormessage.</p>

<p>Can you pls help me?
Thanks for your advice</p>