Good day!
How can I display my JSON Data into a table? this is the json data that im getting..
{"total":1,"per_page":6,"current_page":1,"last_page":1,"from":1,"to":1,
"data":{"id":999,
"firstName":"user999",
"lastName":"lastname999",
"middleName":"middlename999",
"company":"999 Company",
"email":"[email protected]",
"phone":"09063330756",
"addressStreet":"999 Street",
"addressCity":"999City",
"addressProvince":"999Province",
"addressPostalCode":2147483647,
"status":null,
"notes":"Supplier999"}]
}
for now Im just trying to figure out how to display my data into the table.. then after that I'll try to paginate it, by the way Im using an AJAX call.
here is my ajax code:
function search(){
var keyWord = $("#searchSupplier").val();
$.ajax({
url: 'api/searchSupplier',
type: 'get',
data: {searchKey: keyWord},
success: function(response) {
$('table#supplierTable tbody').html("<tr><td>"+response.data+"</td></tr>");
}
});
}
I tried to:
console.log(response.data) = undefined
and
console.log(response) = the JSON data above.
here is my laravel code:
public function getSuppliers()
{
$input = Input::get('searchKey');
return Supplier::where('firstName', 'like', '%'.$input.'%')->paginate(6)->toJson();
}
Thanks in advance.