I used arrays for my table :
var html = [];
$.each(data,function(index,item){
no++;
var arr = [
'<tr>',
'<td>'+ no +'</td>',
'<td>'+ item.name +'</td>',
'<td>'+ item.address +'</td>',
'<td>',
'<button type="button" class="btn btn-info btn-sm" onclick="pickData('+ item.id +','+ item.name +','+ item.address +')"><i class="fas fa-plus-circle"></i></button>',
'</td>',
'</tr>'
].join('\n');
html.push(arr);
});
$('#table').html(html);
and this is the function :
function pickData(id, name, address) {
$("#id").val(id);
$(".name").val(name);
$(".address").val(address);
}
The error is :
Uncaught SyntaxError: missing ) after argument list
Where is the problem?
From the way you write code, Please check your variable (especially address and name) value from console.log, Make sure it doesn't contains space on it.
Ie. "Malibu" Vs "Malibu street",
If it does contains space, you need to quotes those variable value. Because when you're not place quotes, your function would be invoked like this: pickData("yourId", "yourName", Malibu street)
Meanwhile the function itself expect like this: pickData("yourId", "yourName", "Malibu street")