How to use jquey ajax to edit the text?
<p>How to use form submit and ajax to edit the text Name &amp; Sex ??
When I click first submit button it only change the first Name &amp; Sex
If click second one just change the second Name &amp; Sex !
How to do it ?</p>

<p>HTMl &amp; JS </p>

<pre><code>&lt;!-- Form1 --&gt;
&lt;form action="index.php" class="form_edit" &gt;
    Name: &lt;span class="display"&gt;Tom&lt;/span&gt;&lt;br&gt;
    Sex: &lt;span class="display_sex"&gt;Male&lt;/span&gt;&lt;br&gt;
    &lt;input type="text" name="name" value="" /&gt;&lt;br&gt;
    &lt;input type="text" name="sex" value="" /&gt;&lt;br&gt;
    &lt;input name="submit" type="submit" value="Submit" /&gt;&lt;br&gt;&lt;br&gt;
&lt;/form&gt;
&lt;!-- Form2 --&gt;
&lt;form action="index.php" class="form_edit" &gt;
    Name: &lt;span class="display"&gt;Mary&lt;/span&gt;&lt;br&gt;
    Sex: &lt;span class="display_sex"&gt;Female&lt;/span&gt;&lt;br&gt;
    &lt;input type="text" name="name" value="" /&gt;&lt;br&gt;
    &lt;input type="text" name="sex" value="" /&gt;&lt;br&gt;
    &lt;input name="submit" type="submit" value="Submit" /&gt;&lt;br&gt;&lt;br&gt;
&lt;/form&gt;
&lt;!-- Form3 --&gt;
&lt;form action="index.php" class="form_edit" &gt;
    Name: &lt;span class="display"&gt;John&lt;/span&gt;&lt;br&gt;
    Sex: &lt;span class="display_sex"&gt;Male&lt;/span&gt;&lt;br&gt;
    &lt;input type="text" name="name" value="" /&gt;&lt;br&gt;
    &lt;input type="text" name="sex" value="" /&gt;&lt;br&gt;
    &lt;input name="submit" type="submit" value="Submit" /&gt;&lt;br&gt;&lt;br&gt;
&lt;/form&gt;

&lt;script type="text/javascript"&gt;

    $('.form_edit').submit(function(){
        $.ajax({
           type: "POST",
           url: "edit.php",
           data: $(this).serialize(),
           success: function(data)
           {
                $('.display').text(data);

            }
         });
        return false;
    }); 
&lt;/script&gt;
</code></pre>

<p>PHP</p>

<pre><code>&lt;?php
if($_POST['name']){

    $return = '{"name":"' . $_POST['name'] . '"}';
    echo $return;

}
?&gt;
</code></pre>
