for loop inside jquery-ajax function in php
<p>I am doing a rating application in php,here I want to write a for loop inside a jQuery ajax function call.I dont know how the correct syntax.</p>

<p>PHP code I used is</p>

<pre><code>for(i=1;i&lt;=4;i++)
{
&lt;div class="like"&gt;
&lt;a href="#" class="like" id="1" name="up"&gt;&lt;img src="images/likebig.png"&gt;&lt;/a&gt;
&lt;a href="#" class="like" id="1" name="down"&gt;&lt;img src="images/dislike.png"&gt;&lt;/a&gt;

 &lt;form&gt;
 &lt;input type="hidden" id="&lt;?php echo $i; ?&gt;" value="&lt;?php echo $_SESSION['r_id'][$i]?&gt;"&gt;
 &lt;/form&gt;
}
&lt;/div&gt;
</code></pre>

<p>The above code gives four results.Here I want to get the value ($_SESSION['r_id'][$i]) of each result on the click of their corresponding click </p>

<p>The jQuery function I used is</p>

<pre><code>&lt;script type="text/javascript"&gt;

    $(document).ready(function()
    {
    $(".like").click(function(e)
    {
    e.preventDefault();
    var id=$(this).attr("id");
    var name=$(this).attr("name");
    var fname = $("#fname").val();
    var lname = $("#lname").val();
    var email = $("#email").val();
    for(var i=1;i&lt;=4;i++)
    {
    var rel[i] = $("#i").val();
    }
    var dataString = 'id='+ id + '&amp;name='+ name + '&amp;fname='+ fname + '&amp;lname='+ lname + '&amp;email='+ email;
     $.ajax
      ({
      type: "POST",
      url: "rate.php",
      data: dataString,
      cache: false,
      });
     });
    });
&lt;/script&gt;
</code></pre>
