title: How to call C# method in jQuery?
body: <p>I am using a chart which should get Input from C# for plotting the graph. I am using JSON for returning the values from C# to jQuery. Anyhow it doesn't help me, what did I do wrong?</p>
  
  <p>This is my aspx code:</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          var source = {};
  
          $.ajax({
              type: 'POST',
              dataType: 'json',
              url: "Default.aspx/getall",
              contentType: 'application/json; charset=utf-8',
              cache: false,
              success: function (response) {
  
                  source = $.parseJSON(response.d);
  
              },
              error: function (err) {
                  alert('Error');
              }
          });
  &lt;/script&gt;
  </code></pre>
  
  <p>And this is my C# code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class sampledata
  {
      public string Day { get; set; }
      public int Keith { get; set; }
      public int Erica { get; set; }
      public int George { get; set; }
  }
  
  public partial class _Default : System.Web.UI.Page 
  {
      List&lt;sampledata&gt; s = new List&lt;sampledata&gt;();
  
      protected void Page_Load(object sender, EventArgs e)
      {
          s.Add(new sampledata { Day = "monday", Keith = 20, Erica = 15, George = 25 });
          s.Add(new sampledata { Day = "tuesday", Keith = 25, Erica = 20, George = 35 });
  
          Session["data"] = s;                  
      }
  
      [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public static List&lt;sampledata&gt; getall()
      {
          List&lt;sampledata&gt; data = (List&lt;sampledata&gt;)HttpContext.Current.Session["data"];
          return data;
      }
  }
  </code></pre>