How to get PHP to update Angular of status of lengthy process?

I have the following Angular site which shows that Angular can update the page while PHP executes some process via AJAX in the background.

However, how can I now get my PHP process, e.g. the for loop to pass back the value of $x so that I can display the follow of $x as it increments?


<!doctype html>
<html lang="en">
      <meta charset="utf-8">
    <body ng-app="mainApp">
Angular is counting: {{counter}}
<button ng-click="processFiles()">processFiles</button>
</div> var mainApp = angular.module('mainApp',[]); function mainController($scope, $interval, $http) { var theTimer = $interval(function () { $scope.counter++; }, 1000); $scope.counter = 0; $scope.message = 'click the button to have PHP do something in the background while Angular should continue to count'; $scope.processFiles = function() { $scope.message = 'processing...'; $http.get('http://localhost/webs/ajaxtest/data.php', { params: { taskIdCode: 'getLoadingStatus' } }).success(function (data) { $scope.message = data['status']; }); } } </body> </html>


        $taskIdCode = filter_input(INPUT_GET, 'taskIdCode', FILTER_UNSAFE_RAW);
        $methodName = 'task_' . $taskIdCode;
    public function task_getLoadingStatus() {
        for($x = 1; $x <= 4; $x++) {
        $data['status'] = 'finished';
        echo json_encode($data);
$taskRunner = new TaskRunner();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s