title: Return Json object from Asp.net webMethod to Ajax call
body: <p>I have following Ajax call method and The asp.net webmethod.</p>
  
  <p>My asp.net function is returning some values I need those back in Ajax call ..</p>
  
  <p>I have tried lot of things but not succeded yet.</p>
  
  <p><strong>AJAX CALL</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  
          $(document).ready(function () {
              // Add the page method call as an onclick handler for the control.
              $("#&lt;%=ddlEmailTemplate.ClientID%&gt;").change(function () {
                  debugger;
                  var myparam = $("#&lt;%=ddlEmailTemplate.ClientID%&gt;").val(); //id name for dropdown list
                  $.ajax({
                      type: "POST",
                      url: "FileTax.aspx/ddlEmailTemplate_SelectedIndexChanged",
                      data: '{param:"' + myparam + '"}',
                      contentType: "application/json; charset=utf-8",
                      success: function (data) {
                          alert(data.d)
                      }
                  });
              });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>WebMethod asp.net</strong> </p>
  
  <p>Updated after your answer</p>
  
  <pre><code>[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
      public static string ddlEmailTemplate_SelectedIndexChanged(string param)
      {
          string subject;
          string Description;
          using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ForMyTaxConnectionString"].ConnectionString))
          {
              con.Open();
              DataSet ds = new DataSet();
              using (SqlCommand cmd = new SqlCommand())
              {
  
                  cmd.Connection = con;
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd.CommandText = "Spo_ShowEmailTemplateContent";
                  cmd.Parameters.Add(new SqlParameter("@Tid", SqlDbType.Int)).Value = Convert.ToInt32(param);
                  using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                  {
                      da.Fill(ds);
                      con.Close();
                      da.Dispose();
                  }
                  if (ds.Tables[0].Rows.Count &gt; 0)
                  {
                      DataRow dr = ds.Tables[0].Rows[0];
  
                      subject = Convert.ToString(dr["TemplateSubject"]);
                      Description = Convert.ToString(dr["TemplateDescription"]);
  
                  }
              }
  
          }
  
          return JsonConvert.SerializeObject(new { subject = subject, description = Description });
          // return subject ;
  </code></pre>