I am just using this code and I wanted to alert its response
$http.post('test.php',{id:index});
so I used this code
alert(($http.post('test.php',{id:index}).data));
I dont understand how angularjs method $http.post is differ from below code. and how data comes in above code ?
$http({
url: "test.php",
method: "POST",
data: {id:index}
}).success(function(data) {
alert(data);
}).error(function(error) {
});
test.php is
<?php
echo "TestName";
?>
successanderrormethods are deprecated: "The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error." So instead of using$http().success().error();use$http().then(function resolved () {}, function rejected () {});See: docs.angularjs.org/api/ng/service/$http#deprecation-notice