I'm passing the values in angularjs using $http
to a url but I'm not able to get the values in AJAX file.
The following is my JS code:
$scope.insert = function() {
var name = $scope.name;
var pass = $scope.password;
alert(name);
alert(pass);
$http({
url : 'http://localhost/anguler/ajax.php?act=abc',
data : {"pass":pass,"name":name},
type : 'POST'
}).success (function(resp){
alert(resp);
});
}
And this is the code in ajax.php:
if(isset($_REQUEST['act']) == 'abc')
{
$user_name=$_POST['name'];
$password=$_POST['pass'];
echo $user_name.'**'.$password;
}
I'm not getting the values for $user_name
and $password
.
Angular $http
has another options, check it out:
$http({
method: 'POST',
url: 'http://localhost/anguler/ajax.php?act=abc',
data: {
"pass": pass,
"name": name
}
})
Not type
, but method
. https://docs.angularjs.org/api/ng/service/$http#post
Also, you can try to check passing values like isset($_REQUEST['pass']) == 'pass') { do stuff; }