I am facing a problem when returning json from a domain.
In one file i have the following
var postData ="domain=testing.gr";
$.ajax({
type: "POST",
dataType: "json",
data: postData,
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/json;charset=UTF-8");
}
},
url: 'http://www.ewebs.gr/advprodigy/adv.php',
success: function(data) {
// 'data' is a JSON object which we can access directly.
// Evaluate the data.success member and do something appropriate...
if (data.success == true){
$('#keimeno').html(data.message);
}
else{
$('#keimeno').html(data.message);
}
}
});
...and in the PHP file I have hardcoded the following:
<?php header('content-type: application/json');
$domain = $_POST['domain'];
// Set up associative array
$data = array('success'=> true,'message'=>'Success message: hooray!');
// JSON encode and send back to the server
echo json_encode($data);
?>
Yet i get an error on returning.. response is empty! http://prntscr.com/x333k