Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, ajax parameter data must be object, not url string. If you want to send string url, add url string to url like this:</p> <pre><code>$.ajax({ url: "dietup.php?&amp;name='+ name + '&amp;kal=' + kal + '&amp;pro=' + pro + '&amp;kar=' + kar + '&amp;yag=' + yag;" }) </code></pre> <p>But it will be wrong approach </p> <p>I have divided yours script into two logical components. First: is php loop generates the html table Second: javascript function, who's sending ajax request</p> <pre><code>&lt;table id="table"&gt; &lt;?php for($i=0; $i&lt;$totalbesin; $i++) { ?&gt; &lt;tr rel="&lt;?php echo $i ?&gt;"&gt; &lt;td class="td name" id="&lt;?php echo "name".$i?&gt;"&gt;&lt;?php echo $besin[$i]['n']?&gt;&lt;/td&gt; &lt;td class="td kal" id="&lt;?php echo "kal".$i?&gt;"&gt;&lt;?php echo $besin[$i]['kal']?&gt;&lt;/td&gt; &lt;td class="td pro" id="&lt;?php echo "pro".$i?&gt;"&gt;&lt;?php echo $besin[$i]['pro']?&gt;&lt;/td&gt; &lt;td class="td kar" id="&lt;?php echo "kar".$i?&gt;"&gt;&lt;?php echo $besin[$i]['kar']?&gt;&lt;/td&gt; &lt;td class="td yag" id="&lt;?php echo "yag".$i?&gt;"&gt;&lt;?php echo $besin[$i]['yag']?&gt;&lt;/td&gt; &lt;td class="ekle" id="yuk&lt;?php echo $i?&gt;"&gt;Ekle&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; &lt;script type="text/javascript" &gt; $(function() { $(".ekle").click(function() { var parent = $(this).closest('tr'); var data = { name: parent.find('.name').val(), kal: parent.find('.kal').val(), pro: parent.find('.pro').val(), kar: parent.find('.kar').val(), yag: parent.find('.yag').val() }; $.ajax({ type: "POST", url: "dietup.php", data: data, cache: false, success: function(html){ $("span#sonuc").text(parent.attr('rel')); } }); return false; }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload