Hello. I need to insert a variable in the URL.
Here is the script:
<script> function testa(el) { var alink = $(el).serialize(); $.ajax({ type: 'POST', url: 'test.php', data: alink, success: function(data) { $("#refotv").text(data); }, }) } </script> And I need to do something like this:
AJAX
var id = $(el).text('#div'); url: 'test.php?id='+id, html
$vv = mysql_query("SELECT * FROM test"); while ($v = mysql_fetch_array($vv)) { echo "<div id='refotv'>"; echo "<a onClick='testa(this);'>".$v[text]."</a><br />"; echo "<div id='div'>".$v[id]."</div><br />"; echo "</div>"; } Displays 5 lines:
Текст 1 1 Текст 2 2 Текст 3 3 Текст 4 4 Текст 5 5 When clicking on the text, it is necessary that it processed exactly the line that it selected and sent via var id = ... , and gave the answer in #refotv in the line in which it was clicked.