title: jqPlot Chart using asp.net MVC, JSON
body: <p>I am new to MVC and jQuery and jqPlot.</p>
  
  <p>Can anyone give example where I can find demo projects or step by step procedure to achive.</p>
  
  <p>What I need is:</p>
  
  <ul>
  <li>How to Return a JSON to view.</li>
  <li>While adding View - it should be partial view or normal view?</li>
  <li>How to get JSON from view using jQuery.</li>
  <li>How to pass JSON object in jqPlot?</li>
  </ul>
  
  <p>Thanks a lot in advance.</p>
  
  <p>===============================================</p>
  
  <p>Tried with below code, it is always going to <strong>ERROR</strong> part, can anyone explain what is the reason?</p>
  
  <pre><code>&lt;!--[if lt IE 9]&gt;&lt;script language="javascript" type="text/javascript" src="../Scripts/excanvas.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
          &lt;script src="../js/jquery-1.3.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" language="javascript" &gt;
              $(document).ready(function () {
                  $("#btnClick").click(function () {
                      alert('Inside Click Function');
                      $.ajax(
                          type: 'GET',
                          url: "JSONSample.aspx/GetItSerialized",
                          processData: true,
                          data: {},
                          contentType: "application/json; charset=utf-8",
                          dataType: "json",
                          success: function (data) {
                              $.each(data.d, function (index, item) {
                                  alert('Inside Success');
                              });
                              //alert('Inside Success');
                              //processData(data);
                          },
                          error: function(jqXHR, textStatus, errorThrown) {alert('Error');}
  
                      });
  
                      function processData(data) {
                          alert('test');
                      }
                  });
              });
          &lt;/script&gt;
  
  
      &lt;body&gt;
          &lt;form id="form1" runat="server"&gt;
          &lt;div&gt;  
          &lt;input id="btnClick" runat="server" value="Click here" type="button" /&gt;
          &lt;/div&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  
  public string GetItSerialized()
          {
              Employee oEmployee1 = new Employee { Name = "ABC", ID = "111", Age = "30" };
              Employee oEmployee2 = new Employee { Name = "FDF", ID = "rtrt", Age = "31" };
              Employee oEmployee3 = new Employee { Name = "dfdf", ID = "fdfd", Age = "20" };
  
              List&lt;Employee&gt; listEmp = new List&lt;Employee&gt;
              {
                  oEmployee1,
                  oEmployee2,
                  oEmployee3
              };
  
              string str = (new JavaScriptSerializer().Serialize(listEmp));
  
              return str;
          }
  
      }
  
      public class Employee
      {
          public string Name { get; set; }
          public string Age { get; set; }
          public string ID { get; set; }
      }
  </code></pre>