Я делаю запрос jsonp, и я получаю эту ошибку Refused to execute script from 'https://myurl/test.php?callback=%27callback%27' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
, несмотря на то, что запрос возвращает код 200.Отказался от выполнения сценария по запросу jsonp
function callback(response){
alert(response);
}
var script = document.createElement("script");
//Set the Type.
script.type = "text/javascript";
//Set the source to the URL the JSON Service.
script.src = "https://myurl/test.php?callback='callback'";
//Append the script element to the HEAD section.
document.getElementsByTagName("head")[0].appendChild(script);
и это test.php
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
?>
[изменить mime-тип вывода в php] (// stackoverflow.com/questions/152006/change-mime-type-of-output-in-php) – Thomas
и [В чем разница между JSON и JSONP?] (//stackoverflow.com/a/2887218/6567275) – Thomas
Ваш PHP-код не возвращает JSONP .... – epascarello