-1

i am a complete newbie with angularjs, i am using $http to send to the server and the php file is very basic. i can get the http retrieving data from an echo. But from i am trying to get the data using return. Any ideas?

$scope.SendData = function () {
        // use $.param jQuery function to serialize data from JSON
        var data = $.param({
            action: "get_clients"
        });

        var config = {
            headers : {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
            }
        }

        $http.post('http://********.co.uk/*******/switchboard.php', data, config)
            .success(function (data, status, headers, config) {
                $scope.PostDataResponse = data;
                console.log($scope.PostDataResponse);
            })
            .error(function (data, status, header, config) {
                $scope.ResponseDetails = "Data: " + data +
                    "<hr />status: " + status +
                    "<hr />headers: " + header +
                    "<hr />config: " + config;
                console.log($scope.ResponseDetails);
            });
    };

the php file is very simple and is just an echo or a return.

<?php
echo "i am from the php file";
 ?>

<?php
return "i am from the php file";
 ?>
Bish25
  • 606
  • 1
  • 10
  • 35

1 Answers1

6

echo renders the text etc into the document, return returns data from a function/method etc to whatever called it. If you echo a return, it'll render it (Assuming it's text/number etc - not an object etc).

You can see here for more infomation

What is the difference between PHP echo and PHP return in plain English?

Community
  • 1
  • 1
Akashii
  • 2,251
  • 3
  • 17
  • 29
  • 1
    See [What is the difference between PHP echo and PHP return in plain English?](http://stackoverflow.com/questions/9387765/what-is-the-difference-between-php-echo-and-php-return-in-plain-english) for more information. – Tom Udding Mar 28 '17 at 08:21
  • okay i was reading a document about echo and return and was getting confused i reckon, thanks – Bish25 Mar 28 '17 at 08:22
  • @tomudding the exact question i was reading – Bish25 Mar 28 '17 at 08:22