In the following code, I get the error: JSFIDDLE
Resource interpreted as Script but transferred with MIME type text/html
$.ajax({
url: "http://cob.cdcs.selu.edu/WEB-APP/VBF-Directory2/api/all.php?callback=?",
async : false,
jsonpCallback: 'jsonCallback',
dataType: 'jsonp'
})
.done(function( data ) {
console.log("Log :" + data);
});
Forgive me for being new with JSONP. I even looked up various resources on Stackoverflow and w3. I could not still figure out.
In the php file $array
is an array and the only code that prints is:,
echo json_ecode($array)
From my research, JSONP is not JSON. It actually should be JavaScript, and you need to wrap your results in the callback function call (callbackName(data);
)
<?= $_GET['callback'] ?>(<?= jsonResult ?>);