Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9281167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:03:05+00:00 2026-06-18T18:03:05+00:00

This function, ajax … every thing is working well. When I want to reload

  • 0

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); ?>);
                      }                      
                }); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:03:06+00:00Added an answer on June 18, 2026 at 6:03 pm

    You have hard-coded your users variable in your javascript:

    <?php  echo "var user_array = [" . json_encode($users) . "];\n"; ?>
    

    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:

    $.ajax({                          
           url: page,
           dataType: "json",                    
           success: function(data) {
                var user_array = data;
                console.log(user_array);
           }                      
    }); 
    

    And your page script should do something like this at the end:

     echo json_encode($users);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have this script: function ajax(){ if (navigator.standalone) return; for (var i= document.links.length;
This is a question in response to thise: Javascript AJAX function not working in
Source $(function reload(){ $.ajax({ . . . window.setTimeout(reload, 3000); }); }); This function reload
i want to call jquery ajax function inside the function like this: function mine(time){
I had a perfectly well working jquery ajax function but I'm making it better.
I need help with one ajax function This is raw page setup. Page will
I have a jQuery AJAX function like this: $.ajax({ url: 'crud/clients.php', dataType: 'json', type:
ajax tutorial on w3school at http://www.w3schools.com/ajax/ajax_database.asp In this function (function GetXmlHttpObject()), it creates a
I execute an ajax function that takes 3 seconds + so in this time
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.