title: Passing json object using AJAX error in code behind
body: <p>I have created an HTML file that will try to pass a json value to my asp page but I get an error on my asp. My HTML works ok and passing values {'a':'a','b':'b'}, but the asp page were not able to use the value.</p>
  
  <ol>
  <li><p>Here is my HTML code and showing the JSON value {'a':'a','b':'b'}:</p>
  
  <pre><code>  &lt;html&gt;
    &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  
    &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt; 
  
      $(document).ready(function() {
      $('#btnAdd').click(function() { 
  
  
          var json_obj = "{'" + $('#t1').val() + "' : '" + $('#p1').val() + "','" + $('#t2').val() + "' : '" + $('#p2').val() + "'}"; 
  
  
          $.ajax({ 
              type: 'POST', 
              url: 'http://localhost/Base_Data/InsertItem.aspx', 
              contentType: 'application/json; charset=utf-8', 
              data: json_obj, 
              dataType: 'json', 
              success: function(msg) { 
                  alert('Success!'); 
              }, 
              error: function(msg) { 
                  alert('Error!'); 
              } 
          }); 
      }); 
    }); 
    &lt;/script&gt; 
    &lt;/head&gt;
    &lt;body&gt;
  
  &lt;div&gt; 
  Type: 1: &lt;input type="text" id="t1" /&gt; 
  Property 1: &lt;input type="text" id="p1" /&gt; 
  
  Type 2: &lt;input type="text" id="t2" /&gt; 
  Property 2: &lt;input type="text" id="p2" /&gt; 
  &lt;input type="button" id="btnAdd" value="Add object!" /&gt; 
  
  &lt;/div&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre></li>
  <li><p>Here is my ASP page code behind:</p>
  
  <pre><code>public class Test
  {
  public Test(string json)
  {
  
      var serializer = new JavaScriptSerializer();
      var result = serializer.DeserializeObject(json);
  
      var first = int.Parse(result["t1"]);
      var second = int.Parse(result["t2"]); 
   }
  
    public string first { get; set; }
    public string second { get; set; }
   }
  </code></pre></li>
  </ol>
  
  <p>Any replies will be highly appreciated. Thanks in advance!</p>