title: Ajax POST Data not being sent to the Page_Load method in ASP.NET
body: <p>I am basically trying to send some test values from my javascript function to the Page_Load method in my ASP.NET Web Forms page. </p>
  
  <p>However, when debugged I noticed that the Request data are null and <strong>does not go through the condition</strong>.</p>
  
  <p>Code:</p>
  
  <p><strong>test.aspx</strong></p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
          &lt;div&gt;
              &lt;input type="button" onclick="senddata()" /&gt;
          &lt;/div&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              function senddata() {
                  var testdata = "checkcheck";
  
                  $.ajax({
                      type: 'POST',
                      url: '/test.aspx',
                      data: { "data": testdata},
                      success: function (msg) {
                          console.log(msg);
                      }
                  });
              }
          &lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Code Behind:</strong></p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      //doesn't go beyond this when I click the button
      if (!string.IsNullOrEmpty(Request.Form["data"]))
      {
          string resp = "working";
          Response.Write(resp );
          Response.End();
          return;
      }
  }
  </code></pre>
  
  <p>Any idea why the data is not received from the code behind? It's a very simple example and I am wondering why.</p>