[eluser]Fireclave[/eluser]
Hey Community,
i try to get Datas with jQuery and Codeigniter (2.0.1) - the Query works.
My Problem is:
I using
JS
Code:
$.post("<?php echo base_url() ?>welcome/get_ajax_course2", { id: 10 }, function(data) {
alert("Data Loaded: " + data );
alert(data.1); // This is not working
alert(data.name);
//$('#wysiwyg_titel').val();
}, "json");
PHP
Code:
echo json_encode($this->db->query()->result_array());
to get the the result. My Problem is: How can i get the values ?
I have tried another examples with Json. Can i Take the Values like:
$data[0]['name'] in Javascript ?
My PHP-Array is like this:
Code:
$data = array(
array(...),
array(...) );
EDIT:
When i use alert(data) i get the following:
Code:
[{"id":"1","actual_role_id":"0","name":"Guest","description":"This is the default role everyone is if they're not logged in. Site visitors are guests until they log in."},{"id":"2","actual_role_id":"1","name":"User","description":"Standard registered user."},{"id":"3","actual_role_id":"2","name":"Client","description":"Client priveleges such as submitting things and editing their own stuff."}]
this is only an example database ;-)
How can i get the description of the second Row ? (data.row2.description ??)