使用Ajax提取数据时出错

I am trying to edit some data using boostrap and ajax, however when I run the code an error occurs.

The error is on the line

onclick="editUser('.$row->id.');"

How do I fix this?

My JavaScript code is

function edit(id) {
    $.ajax({
        url : "<?php echo site_url('edit')?>/" + id,
        type: "GET",
        dataType: "JSON",
        success: function(data)
        {
            $('[name="name"]').val(data.name);
            $('[name="id"]').val(data.id);
            $('[name="name"]').focus();
            $('#edit').modal('show'); // show bootstrap modal when complete loaded
        },
        error: function (jqXHR, errorThrown)
        {
            alert('Error ajax');
        }
    });     

}

My HTML code is

<?php
    $no = 1;
    foreach ($user as $row) {               
    ?>
    <tr>
    <td><?php echo $no; ?></td>
    <td><?php echo $row->nik; ?></td>
    <td><?php echo $row->id; ?></td>
    <td><?php echo $row->name; ?></td>                  
    <td align="center">
        <a href="javascript:void(0)" onclick="editUser('.$row->nik.');" class="btn btn-warning"><span class="glyphicon glyphicon-pencil"></span></a> &nbsp;
    </td>
<?php $no++; }?>

You have a bit of php/javascript soup. Your href value needs to be enclosed in php tags. Change:

 onclick="editUser('.$row->nik.');" 

to

 onclick="editUser('<?php echo $row->nik;?>');" 

An addition to the hairmot's answer:

You would also like to escape any characters that would interfere with the html:

onclick="editUser('<?php echo htmlspecialchars($row->nik) ?>');"