Display JSON results

I have a JSON function that works fine but I want to know how to display all of the results without using a for loop my code is below:

function newarticlescallback(rtndata)
	$('#pagetitle').html("New Articles");
	var data="";
	for(var j=0;j<9;j++)

         data = data + "<li><a href='#' onclick=\\"History.pushState({state:null},'article,"+rtndata[j].id+"','article'); return false;\\">" + rtndata[j].title + "</a></li>";

You can’t, it has to be a loop. Any particular reason you don’t want a loop?

I know it has to be a loop but i am looking for a loop that can go through the JSON without knowing how much results are in the JSON object for instances if i want to do select all from my db i would like my loop to handle that query without modification

It’s less expensive to send all of the required data at once, than to loop around multiple request/wait processes.

Send a request to your server letting your server know that you want to get all of the relevant data, and then handle that data when it’s send to the client page.

Hi paul,

rtndata has all the data within it within the for loop I just add html to each datarow, but I know the amount of rows of data I have. But what happens if I have more or less rows of data? I want a function that handles any number of rows of data. Like a while EOF or something to that extent.

You can use rtndata.length in the for loop instead, so that it loops over whatever number of items are in the array.

really thanks a lot paul