I`m trying to load an php file to the bottom of my page without page refresh, I have a set of links within a while loop that post the specific ‘lead_id’ of the record clicked. This works fine with a page refresh but, I would like to do it without.
I have made a start but, my code will only spit out the first ‘lead_id’ in the record and not the specific one clicked.
Hope this all makes sense, here is my code:
function my_onclick()
{
$.post("ajax/pending-admin-details.php",
{'lead_id': $("#input").val()},
function(data)
{
$("#content").html(data);
}
);
}
and the while loop:
while ($row = mysql_fetch_row($main_query))
{
$row[] = '<input type='button' id='input' value='{$row[0]}' onClick='javascript:my_onclick();'>'; /* i`m using a button to get the value of current lead_id */
$row[] = "<a href='../ajax/pending-admin-details.php?id={$row[0]}' class='myClass_'><img src='../images/delete.png' alt='' /></a>";
$row[] = "<a href='../ajax/pending-admin-details.php?id={$row[0]}'><img src='../images/delete.png' alt='' /></a>";
$response['aaData'][] = $row;
}
Any feedback would be great as this has had me in circles for 2 days now.
cheers
The problem lies here
$(“input”).val() will always return the value of the first input in your page.
It should be something like below.
PHP
Javascript