title: Update div on AJAX submit jQuery is updating all divs
body: <p>I'm trying to update a div with an ajax post.  Problem is...it's updating every div.</p>
  
  <p>Here's the json.php:</p>
  
  <pre><code>//json.php
  
  $data['months'] = $db-&gt;escape_value($_POST['check']);
  $data['id'] = $db-&gt;escape_value($_POST['hidden']);
  
  
  $query = "UPDATE month SET months = '{$data['months']}' WHERE monthID = '{$data['id']}'";
  $result = $db-&gt;query($query);
  
  if($result) {
    $data['success'] = true;
    $data['message'] = "Update Successful!";
    $data['text'] = $_POST['check'];
    echo json_encode($data);
  } else {
    $data['message'] = "Update could not be completed.";
  }
  </code></pre>
  
  <p>And the html:</p>
  
  <pre><code>&lt;?php
  
  $query = $db-&gt;query('SELECT * FROM month');
  
  
  ?&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;jQuery/Ajax - Update is updating all divs&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="test.css" /&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
  
    $("input.check, button.save, input.cancel, div.message").hide();
  
    $(".edit").click(function(){
        $(this).parent().siblings("li.liTwo").children("input.delete").hide();
        $(this).parent().siblings("li.liThree").children("button.save").show();
        $(this).parent().siblings("li.liFour").children("input.cancel").show();
        $(this).parents("ul").siblings("div.showText").hide();
        $(this).parents("ul").siblings("input.check").show();
        $(this).hide();
        return false;
      });
  
    $(".cancel").click(function(){
        $(this).parent().siblings("li.liTwo").children("input.delete").show();
        $(this).parent().siblings("li.liThree").children("button.save").hide();
        $(this).parent().siblings("li.liOne").children("input.edit").show();
        $(this).parents("ul").siblings("div.showText").show();
        $(this).parents("ul").siblings("input.check").hide();
        $(this).hide();
        return false;
      });
  
  
    $("form[name=form1]").submit(function(){
      var params = $(this);
      $.post("json.php", { hidden : $(this).find("[name=hidden]").val(), check :   $(this).find("[name=check]").val() },
        function (data){
          if(data.success) {
            $(".showText").html(data.text);
            $(".message").html(data.message).slideDown("fast");
            $(".check").hide();
            $("button.save").hide();
            $(".cancel").hide();
            $(".edit").show();
            $(".delete").show();
            $(".showText").show();
            return false;
          }
        }, "json");
      return false;
    });
  
  
  
  });
  &lt;/script&gt;
   &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="message"&gt;message&lt;/div&gt;
      &lt;?php while($row = $db-&gt;fetch_assoc($query)) { ?&gt;
      &lt;form action="json.php" name="form1" method="post"&gt;
        &lt;div class="container"&gt;
            &lt;div class="showText"&gt;&lt;?php echo $row['months']; ?&gt;&lt;/div&gt;
            &lt;input name="check" type="text" class="check" value="&lt;?php echo $row['months']; ?&gt;" /&gt;
            &lt;input name="hidden" type="hidden" class="hidden" value="&lt;?php echo $row['monthID']; ?&gt;" /&gt;
            &lt;ul class="list"&gt;
              &lt;li class="liOne"&gt;
                &lt;input name="edit" type="button" class="edit" value="edit" /&gt;
              &lt;/li&gt;
              &lt;li class="liTwo"&gt;
                &lt;input name="delete" type="submit" class="delete" value="delete" /&gt;
              &lt;/li&gt;
              &lt;li class="liThree"&gt;
                &lt;button name="save" type="submit" class="save" value="&lt;?php echo $row['monthID']; ?&gt;"&gt;save&lt;/button&gt;
              &lt;/li&gt;
              &lt;li class="liFour"&gt;
                &lt;input name="cancel" type="button" class="cancel" value="cancel" /&gt;
              &lt;/li&gt;
            &lt;/ul&gt;
        &lt;/div&gt;
      &lt;/form&gt;
      &lt;?php } ?&gt;
  &lt;!--&lt;a id="reset" href="test3.php"&gt;reset&lt;/a&gt;--&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>