title: How to send data from JQuery Ajax to ASP.NET page?
body: <p>I'm using <code>JQuery Ajax</code> to send a data from one domain to an <code>ASP.NET</code> page that is in another domain. I'm able to get the response back from <code>ASP.NET</code> page but I'm not able to send the data from <code>JQuery Ajax</code>. Here is my code:</p>
  
  <pre><code>        $.ajax({
              url: 'http://somewebsite/dbd/leap.aspx',
              data: '{ year: "' + $('#txtYear').val() + '"}',
              type: 'POST',
              async: true,
              cache: false,
              dataType: 'jsonp',
              crossDomain: true,
              contentType:"application/json; charset=utf-8",
              success: function (result) {
                  console.log("inside sucess");
                  console.log("result: " + result);
              },
              error: function (request, error) {
                  // This callback function will trigger on unsuccessful action                
                  alert('Error!');
              }
          });
  </code></pre>
  
  <p>I can reach <code>leap.aspx</code> page. Note <code>http://somewebsite</code> is just a placeholder.</p>
  
  <p><code>leap.aspx</code> has the following:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="leap.aspx.cs" Inherits="_Default" %&gt;
  &lt;%=output %&gt;
  </code></pre>
  
  <p><code>leap.aspx.cs</code> has the following: Note I'm using <code>Request.Params["year"]</code> to get the value of year passed by <code>Ajax</code> call but no luck.</p>
  
  <pre><code>using System;
  
  public partial class _Default : System.Web.UI.Page 
  {
  public string output = "";
  protected void Page_Load(object sender, EventArgs e)
  {
  if (Request.Params["callback"] != null)
      {
          output = Request.Params["callback"] + "('" + GetData(Request.Params["year"]) + "')";
      } 
  }
  
  [System.Web.Services.WebMethod]
  public string GetData(string year)
  {  
  return "From outer space! " + year;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I run this code, in console I see </p>
  
  <blockquote>
    <p>"result: From outer space!"</p>
  </blockquote>
  
  <p>but I do not see the data sent for year by <code>Ajax</code>.  I'm using <code>JSONP</code> because I'm making a cross-domain request to get around Same Origin Policy. I'm not getting any error.  I'm just not getting the getting the value of year returned from <code>ASP.NET</code> page.</p>
  
  <p>How do I get the year?</p>