TestApp.controller('MainCtrl', ['$scope','$http', function ($scope,$http) { $http.post('test.php') .success(function(data){ console.log(data) }) .error(function(data,status){ console.log('error'); }) }]) 

test.php

 <?php echo false; 
  • Where exactly do you think TRUE? The only positive result that your snippet can return is a callback SUCCESS - Oceinic
  • if I write in success like this .success (function (data) {console.log ('ok')}) then it always writes ok in the console - Mark Petrosyan

2 answers 2

You most likely mean that always success, go to the Chrome debugger there will be a server response in the network, since the request was successful then data.result == SUCCESS for this and true.

    • beforeSend occurs immediately before sending a request to the server.
    • error occurs in case of unsuccessful execution of the request.
    • dataFilter occurs when data arrives from the server. Allows you to process the raw data sent by the server.
    • success occurs in case of successful completion of the request.
    • complete occurs in the event of any request completion.