I am currently faced with the task of extracting data from a third-party feed that provides a JSON file. Unfortunately, I do not have access to the server to enable CORS, so after conducting some research I learned about using JSONP. When checking the Chrome network tab, I can see the callback response but I encounter an issue trying to read the file in the console log. Despite executing the code provided below, I continuously receive the following Error Message. Disabling MIME type checking is not an option for me. I have explored other questions related to this problem but haven't found a solution yet. What steps should I take?
"Refused to execute script from '' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled."
<script src="jquery.js"></script>
<script>
$.ajax({
type: 'GET',
url: 'siteurl.com/json?callback=jsonp',
dataType: 'jsonp',
xhrFields: {
withCredentials: false
},
headers: {
"Accept" : "application/json; charset=utf-8",
"Content-Type": "application/javascript; charset=utf-8",
"Access-Control-Allow-Origin" : "*"
},
success: function (result) {
console.log(result);
},
error: function (xhr, errorText) {
console.log('Error ' + xhr.responseText);
}
});
</script>
Review the network tab for more insights:
Network tab view