Can someone tell me what I'am doing wrong here, console.log()
returns me an empty string instead of an array ?
I want to update the second selectbox once onChange is triggered on first selectbox but I can't retrieve the data. When I'am doing a var_dump($results)
it successfully shows an array of items, but return $results
returns me an empty string.
Here how it looks like:
a javascript:
function _getNestedSelectOptions(activeComponent){
$.ajax({
type: "POST",
url: "/backend/categories/get_nested_options/" + activeComponent
}).done(function(html){
console.log(html);
});
}
And this is a php code controllers/backend/categories.php
:
public function get_nested_options($cid = FALSE){
if($cid == FALSE)
$cid = $this->activeComponent;
$categoriesResult = $this->categories_model->get_categories_tree_by_com($cid);
$categoriesDropdownOptions = array();
$this->categories_model->get_nested_options($categoriesDropdownOptions, $categoriesResult);
var_dump($categoriesDropdownOptions); // <-- THIS WORKS AND SHOWS AN ARRAY OF ITEMS
//return $categoriesDropdownOptions; // <-- THIS DOES NOT WORKING
}
here is an output on console.log()
:
7 => string 'Administrators' ->(length=14)
8 => string 'Managers' ->(length=8)
9 => string 'Users' ->(length=5)