Anyone know why my ajax fails?
I am getting the data through JSONP from here:
JSON Data
You can use this code, and notice how the ‘Alert’ is never executed:
$(document).ready(function() {
var url = "http://www.finddata.org/buytimeseriesdata/getEncomChartSeriesData?_=1317741441988&tsId=F000008DDB";
$.getJSON(url + "&callback=?", null, function(data) {
alert('hi');
});
});
No you are not getting any JSONP data. You are getting JSON data which is not the same notion. It seems that the url you have indicated doesn’t support JSONP which is the reason why your code doesn’t work. The response must be wrapped with the callback parameter you are specifying but the server ignores it.
For example if you want this to work, the following url must return:
instead of (which it currently does):
I would recommend you reading the following guide if you want to perform corss domain AJAX requests.