Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How do I get an AngularJS http post to a PHP file?

json angular php javascript

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 AzmatZuberi

AzmatZuberi

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 23 November 2015 - 08:36 PM

I'm trying to decipher how to get the json post from a JavaScript file to a PHP file.

This is my JS file:

var url2 = '/php/extractkeywords.php';
var jsonData = angular.toJson({
text: $scope.userTyping,
data: post
});

$http({
url: url2,
method: "POST",
data: "data=" + window.btoa($scope.textHTML),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function (data, status, headers, config) {
// Sending to extractkeywords.php
})

And this is my PHP file:

$data = json_decode(urldecode(base64_decode($_POST["data"])));

When I try to print $data, I don't get anything.

 

 

Attached Files