I am trying to receive and print json with this php code:
<?php
$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
?>
I am not receiving or printing any data. But if i use this ajax:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script>
(function($){
function processForm( e ){
$.ajax({
url:'http://mydyndns:8010/has/input_parameters_startReg.php',
dataType: 'json',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ DeviceID: 23, ForceReg: 0, StartTime: "10/06/2015 17:45"}),
success: function (data) {
},
error: function (e) {
alert(e.responseText);
},
});
e.preventDefault();
}
$('#my-form').submit( processForm );
})(jQuery);
it is working, and i get the posted data printed in my browser. How can i alter my php so the direct hitting from browser will give me the result the ajax gives?