Skip to content

Instantly share code, notes, and snippets.

@manviny
Last active August 29, 2015 13:56
Show Gist options
  • Save manviny/8801006 to your computer and use it in GitHub Desktop.
Save manviny/8801006 to your computer and use it in GitHub Desktop.
JS => PHP (PW guardar JSON)
angularfile.js
$http({
url: 'myurl/myfile.php',
method: "POST",
data: { 'data' : 'hi' }
})
.then(function(response) {
console.log(response);
},
function(response) { // optional
alert("fail")
});
myfile.php
<?php
function getPost(){
$request = file_get_contents('php://input');
return json_decode($request,true);
}
$getPost = getPost();
$myData = $getPost['data'];
return $myData;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment