ドメインからjsonを返すときに問題が発生します。
1つのファイルに私は次のものを持っています
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);
}
}
});
...そしてPHPファイルで私は以下をハードコーディングしました:
<?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);
?>
それでも、戻るとエラーが発生します。応答は空です。 http://prntscr.com/x333k