Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: console.log looping json data but display not

chris keenan:

I'm trying to display Json data on the page, however when sending the Output to html it only displays the last id.

When using console.log it loops through each id available but not on the page output itself


var username = $("#usernameinfo").text();

$.ajax({
type: "GET",
dataType: 'json',
url: "= base_url()?>"+"account/listings/more_user_ads",
data: {
"username": username,
"pid": "=$this->input->get('pid')?>"
},
success: function(res){
for (var i = 0; i var output = "";
var object = res[i];

output = "

" + object.id + "

";
$("#tg-authoradsslider").html(output);
// outputs only the id of 3 which is the last id in the loop

console.log(output);
/* consoles.logs

1


2


3

*/
}
}
});



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: console.log looping json data but display not

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×