title: Getting error during call webservices methods using jquery
body: <p>Getting error during call web service method using java script.</p>
  
  <p>I want to insert data using web service &amp; java-script. Please help</p>
  
  <pre><code>&lt;script src="../js/jquery-1.9.0.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
      function displayMessageCall() {
          //alert("asd");
          $.ajax({
              type: "POST",
              contentType: "application/json",
              url: "http://domain.com.com/demo.asmx/InsertData",
                data: "{ sUserName: 'Aidy', sEmailId: 'F' }",
              dataType: "json",
              success: function (data) {
                  alert(data.d);
  
              },
  
              error: function (XMLHttpRequest, textStatus, errorThrown) {
                  alert(textStatus);
              }
          });
      }
  
      function successMsg(response) {
          alert('Success');
      }
  
      function errorMsg(response) {
          alert(response.status + " " + response.statusText)
      }
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I have use fallowing code to call web services methods</p>
  
  <pre><code> [WebMethod]
  public static string InsertData(string sUserName, string sEmailId)
  {
  
      string sResult = string.Empty;
      try
      {
          sResult = ExecuteScalar("INSERT INTO vg_demo(UserName, EmailId)VALUES('" + sUserName + "','" + sEmailId + "')").ToString();
      }
      catch
      {
          sResult = "101";
      }
      return sResult;
  }
  
  public static string ExecuteScalar(string sQuery)
  {
  
      string sValue = string.Empty;
      SqlCommand oCommand;
      try
      {
          SqlConnection oConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["MySite"].ConnectionString);
          oCommand = new SqlCommand(sQuery, oConnection);
          oCommand.CommandType = CommandType.Text;
  
          using (oConnection)
          {
              oConnection.Open();
              sValue = Convert.ToString(oCommand.ExecuteScalar());
          }
      }
      catch (Exception ex)
      {
          ApplicationError.LogErrors(ex);
      }
  
      return sValue;
  }
  </code></pre>
  
  <p>I am getting 0 error from errermsg function</p>