title: How do i set the value of a hidden field for ajax post datastring in jquery?
body: <p>My form is:</p>
  
  <pre><code>&lt;form method="POST"&gt;
  &lt;input type="hidden" name="params" id="defaultform" value="{"action":"delete","data_id":"123456"}" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>my jQuery is:</p>
  
  <pre><code>$(document).on('click', '#deleteItem', function(e) {
  
      var dataString = $('#defaultform').val();
  
      $.ajax({
          type: "POST",
          url: "functions.php",
          data: dataString,
          cache: false,
          success: function(data){
              var response = $.parseJSON(data);
              if (response.totalrecords &gt; 0) {
                  alert(response.totalrecords);
              }
          }
      });
      return false;
  });
  </code></pre>
  
  <p>my function.php is:</p>
  
  <pre><code>$action = $_POST['action'];
  $data_id = $_POST['data_id'];
  //some php codes
  $response = array('totalrecords' =&gt; $count);
  echo json_encode($response);
  </code></pre>
  
  <p>but JavaScript code can not send POST variables, $_POST['action'] and    POST['data_id'];</p>
  
  <p>How do I edit dataString value in jQuery code?
  I want like this formed:</p>
  
  <pre><code>data : {"action":"delete","data_id":"12456"},
  </code></pre>