title: jquery ajax pass parameters to webservice
body: <p>I have to functions in a web service, one of them works correctly receiving two parameters and i can execute it but the other one that also receives parameters doesn’t work ill paste this function and my Ajax code so you can help me to see what's happening.   </p>
  
  <pre><code>html
  
  &lt;script type="text/javascript"&gt;
      function CallService() {
          $.ajax({
              type: "POST",
              url: "findMe.asmx/locateMe2",  
              crossDomain:true,
              data: '{value1: ' + $("#txtValue1").val() + ', value2: ' + $("#txtValue2").val() + '}',
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: OnSuccess,
              error: OnError
          });
  
      }
  
      function OnSuccess(data, status) {
          $("#lblResult").html(data.d);
  
      }
  
      function OnError(request, status, error) {
          $("#lblResult").html(request.statusText);
  
      }
  
  
  &lt;/script&gt;    
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="frmCoords" runat ="server" &gt;
      &lt;div&gt;
  &lt;table&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  Value 1:
              &lt;/th&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="txtValue1" runat="server" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  Value 2:
              &lt;/th&gt;
              &lt;td&gt;
                  &lt;asp:TextBox ID="txtValue2" runat="server" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;asp:Button ID="btnGo" Text="Go" OnClientClick="CallService(); return false;" runat="server" /&gt;
  
  &lt;asp:Label ID="lblResult" Text="&amp;nbsp;" Width="100%" runat="server" ForeColor="black"  /&gt;
      &lt;/div&gt;
  
  &lt;/form&gt;
  
  
  --webservice
  [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [System.ComponentModel.ToolboxItem(false)]
  // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
  [System.Web.Script.Services.ScriptService]
  
  
      [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  
      public int Add(int value1, int value2)
      {
          return value1 + value2;
      }
  
      public string locateMe2(Double value1, Double value2)
      {
  
          FormClosingEventArgs ee = new FormClosingEventArgs(CloseReason.UserClosing, false);
          DialogResult dlgResult = MessageBox.Show("", "Cadena", MessageBoxButtons.OK, MessageBoxIcon.Information);
  
          SqlConnection Conn = new SqlConnection();
          Conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Audi.Properties.Settings.ConexionSql"].ConnectionString);
          string procedure = "usp_PointInPolygon";
  
          SqlCommand cmd = new SqlCommand(procedure, Conn);
          SqlDataReader reader;
  
  
          //cmd.CommandText = "usp_PointInPolygon";
          cmd.CommandType = CommandType.StoredProcedure;
          //cmd.Parameters.Clear();
          SqlParameter param1;
          SqlParameter param2;
          param1 = cmd.Parameters.Add("@lat", SqlDbType.Float,14);
          param2 = cmd.Parameters.Add("@lng", SqlDbType.Float,14);
  
          param1.Value = value1;
          param2.Value = value2;
  
          Conn.Open();
  
          reader = cmd.ExecuteReader();
          string column = "";
          while (reader.Read())
          {
              column = reader["county"].ToString();
              //int columnValue = Convert.ToInt32(reader["ColumnName"]);
          }
          Conn.Close();
  
          return column;
  
      }
  </code></pre>
  
  <p>The function Add works fine, it receives two int values, the function locateMe2 who receives also to values that are lat and lng and are floats doesn't work, do you see something wrong?</p>
  
  <pre><code>the locateMe2 function will return just a string
  </code></pre>