well I havn’t really ever using jquery to grab data from a server.. and well my jquery skills are pretty limited anyway so maybe im doing the jquery wrong …im not sure
heres my controller to handle the json requests
class Controller_Json extends Controller_Template{
public function get_chat_entries(){
echo json_encode($this->db->get('chat_entries')->result());
}}
and heres my view that is meant to test it
<ul id="chats">
</ul>
<script>
$.getJSON('ajax/test.json', function(data) {
$('#chats').html('<li>' + data.text + '</li>');
});
</script>
I tried your code in my test base kohana. your js code is ok.
problem is mysql_resoure to json conversion.
i.e.
"echo json_encode($this->db->get('chat_entries')->result());"result method returns mysql_resoure which needs to be converted into array.
it works when if i put like this
…
…
only one email is displayed inside of #chats ul list.
PS: emails is my table contains multiple email address