Answer the question
In order to leave comments, you need to log in
Why does it always return TRUE?
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');
})
}])
<?php
echo false;
Answer the question
In order to leave comments, you need to log in
I don't know Angular.
But if you expect .error to be executed, the server should return an http error code.
just false is also a value and does not mean that it is an error
TestApp.controller('MainCtrl', ['$scope','$http', function ($scope,$http) {
$http.post('test.php')
.success(function(data){
console.log(data.message)
})
.error(function(data,status){
console.log('error');
})
}])
<?php
echo '{"message":false}';
?>
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');
})
}])
<?php
echo 'false';
?>
first use echo json_encode(['message' => true]);
secondly, specify the type of content to be transferred in the header;
thirdly, look at the results of the request to begin with
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question