Having a spot of problem with a very simple example using PHP and jQuery.
PHP File
<?php
// This is where we return all of our initial widget markup
header('Content-Type: application/json');
$markup = array('markup' => 'No markup here');
echo json_encode($markup);
JS Function
jQuery(document).ready(function($) {
var widgetURL = "http://samedomain.com/vip/php/markup.php?callback=?";
$.getJSON(widgetURL, {
format: "json"
}).done(function( data ) {
console.log('Success!')
}).fail(function (data) {
console.log('Failed!');
});
});
However every time it fails. Even though checking the JSON shows it to be valid in the response. e.g. The headers say 200OK and list my valid JSON.
Valid JSON Returned with 200 OK response {"markup":"No markup here"}
Why then does the function fail?