Im parseing a JSON file and add the data to a HTML
dropdown , code as follows,
$.getJSON(
"http://mobile.icta.lk/services/railwayservice/getAllLines.php?lang=en&jsoncallback=?",
function(data) {
var $s = $('.txtline').empty();
// the actual contents of this loop will be
// specific to the data
for (var k in data) {
$('<option></option>')
.val(data[k].value)
.text(data[k].text)
.appendTo($s);
}
}
)
Im getting a error as,
Resource interpreted as Script but transferred with MIME type application/json.
getAllLines.php:2Uncaught SyntaxError: Unexpected token :
The problem is that this remote server returns JSON, not JSONP. It returns:
instead of:
You will not be able to consume a remote domain using AJAX unless this remote resource supports JSONP.
Here is a little script:
Usage: