I’ve been searching arround and I can’t retrive JSON information from this example. Can anybody help me please?
var jsonURL = "http://mdc2.cbuc.cat/dmwebservices/index.php?q=dmGetCollectionList/json";
var jqxhr = $.getJSON(jsonURL, function(data) {
alert("Success!");
alert(data[0].alias);
})
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });
jqxhr.complete(function(){ alert("second complete"); });
I’ve checked the URL and everywhere it says that is valid and well formated…
Since that request is not returning proper jsonp, the browser can’t interpret it.
If you have access to that server, it would need to be modified to accept a callback function such as
?callback=cbfuncwhich would then wrap the json response in a callback function, such ascbfunc(["foo","bar"]);If you do not have access to that server, you can either use a 3rd party solution such as YQL, or you can build a server-side proxy that will make the request for you. For YQL, here’s a page that can help:
http://developer.yahoo.com/yql/console/#h=SELECT%20*%20FROM%20json%20WHERE%20url%3D%22http%3A//mdc2.cbuc.cat/dmwebservices/index.php%3Fq%3DdmGetCollectionList/json%22
choose the json radio button, then at the bottom of the page you’ll find a url. just remove the
callback=cbfuncpart.This is the url that was generated:
If the request contains any sensitive data, i would suggest against YQL and for using a server-side script to get the data.