Hi,

I'm having a bit of trouble getting a function to pass a variable to
an ajax function

This is the function....

function display() {
                $.ajax({
                type: "GET",
                url:  "moreinfo.php",
                data: "id=A01",
                success: function (data) {
                $('#content').empty();
                $('#content').append(data);
                }
                });
             }


If the above function is called like this....

while($row = mysql_fetch_array($query)) {
        $auid = $row['au_id'];
        echo "<tr>";
        echo    "<td class='body'><a href='#' onClick='display();'>".$auid."</
a></td>";
        echo    "<td class='body'>".$row['au_fname']."</td>";
        echo    "<td class='body'>".$row['au_lname']."</td>";
        echo "</tr>";
}

The function works fine....

but if i change it to use a variable....

function display(auid) {
                $.ajax({
                type: "GET",
                url:  "moreinfo.php",
                data: "id=" + auid,
                success: function (data) {
                $('#content').empty();
                $('#content').append(data);
                }
                });
}


while($row = mysql_fetch_array($query)) {
        $auid = $row['au_id'];
        echo "<tr>";
        echo    "<td class='body'><a href='#' onClick='display($auid);'>".
$auid."</a></td>";
        echo    "<td class='body'>".$row['au_fname']."</td>";
        echo    "<td class='body'>".$row['au_lname']."</td>";
        echo "</tr>";
}

it doesn't seem to work....

I'm not sure what i'm missing...

Thanks

Michael


P.S. i've tried creating a test function something like test(auid)

function test(auid) {
alert(auid);
}

but again it seems I'm missing something!!!

Reply via email to