Step1:
On PHP side add an action for requesting the values:
<?php
$myValues = array(); // maybe from database?
header('Content-type: application/json');
echo json_encode($myValues);
?>
This is your controller action for sending JSON data to the client side.
Step2:
On client-side: (a) add jQuery and then (b) do a ajax call to fetch the data from your action above, like so:
$.getJSON( "index.php?getValueAction", function( data ) {
alert(data);
// to access the individual properties you would do
alert(data.property);
// use jquery selectors to target the element, where you want the content
$("#myDiv").append(...);
// you should create a proper html element before inserting it :)
}
The first argument of the getJson() call depends on your Codeigniter routing configuration.
Some have /index/forum/show, others have index.php?controller=forum&action=show.
Insert the URL style you use, to make the request to CI.
The this answer does the iteration on client-side JS and prepares a dom-element for insertion, right.
--
An alternative would be to keep the PHP part like you have it and send the whole HTML part over on an AJAX request. That's not very nice, but works. Then it's a basic Ajax Get request to the controller/action providing the HTML fragment.
$.get( "URL", function( data ) {
$("#myDiv").html( data );
});