This function, ajax … every thing is working well.
When I want to reload the $users it return the same $users
Is there any way after loading ajax to reload the $users with new data?
Controller
function list_of_users_by_skills($project_ids){
$project_id = json_decode($project_ids);
/* Generate Users by Skills
* By Isaac
*/
$this->loadModel('Training');
//Get list of users by skills
$users_return = $this->Training->find('all', array('conditions' => array('Training.Project_id' => $project_id)));
//some code here to return the $users :)
asort($users);
$this->set('users', $users);
}
View
var page = 'http://localhost/index.php/shifts/list_of_users_by_skills/[176,196]/';
console.log(page);
$.ajax({
url: page,
success: function(data) {
<?php echo "var user_array = [" . json_encode($users) . "];\n"; ?>
console.log(user_array);
console.log(<?php echo json_encode($users); ?>);
}
});
You have hard-coded your users variable in your javascript:
This will only be filled once, on the initial page request.
You need to make sure that the script that you are calling with ajax, returns the actual user list and use that:
Something like:
And your
pagescript should do something like this at the end: