I have a function something like this:
$('#btn-load-more').click(function(){
var key = $('#hash').val(), limit = 0, i = 0;
setTimeout(function(){
$.post('api', {type: 1, limit: limit, key: 128921}, function(res){
console.log(res);
});
}, 500);
});
The problem is that when you click the button and trigger the event, the result in the console looks exactly like this:
[{"title":"Título de teste","thumb":"2","views":"920134"},{"title":"lorem
ipsum teste inskl","thumb":"2","views":"920134"}]
When the result should be multiple objects. As in the example below:
(2) [Object, Object]
▼ 0: Object
thumb: "2"
title: "Título de teste"
views: "920134"
▶ 1: Object
But my goal was to return an object, such as when I change the $.post
to $.getJSON
, what am I doing wrong?