Reputation: 1145
How i use jQuery.getJSON() to obtain data for this URL?
http://gbrds.gbif.org/registry/organisation/a3c228d0-3110-11db-abb8-b8a03c50a862.json?op=contacts
If i look the result in a browser, i get this result:
[{"position":"","lastName":"","phone":"+39 06 6118286","type":"technical","city":"","country":"","isPrimaryContact":true,"postalCode":"","address":"","email":"[email protected]","description":"","province":"","firstName":"Milko Skofic","salutation":"","key":"48"},{"position":"","lastName":"","phone":"39-06-6118204","type":"administrative","city":"","country":"","isPrimaryContact":true,"postalCode":"","address":"IPGRI, Via Tre Denari, 472/a, 00057, Maccarese, Rome, Italy,","email":"[email protected]","description":"","province":"","firstName":"Ms. Sonia Dias","salutation":"","key":"49"}]
Upvotes: 0
Views: 200
Reputation: 38626
Take a look at the getJSON
method on the jQuery documentation.
The sintaxe:
$.getJSON(url, data, function success);
So, you can try something like this:
$.getJSON("http://gbrds.gbif.org/registry/organisation/a3c228d0-3110-11db-abb8-b8a03c50a862.json?op=contacts", null, function(data) {
// loop in your result if it is an array
$.each(data, function(i, item) {
// use data[i].property to access each property of your array.
// for sample:
var p = data[i].position;
var l = data[i].lastName;
});
});
Upvotes: 1
Reputation: 227310
You need to use JSONP because it's not on the same domain.
$.getJSON("http://gbrds.gbif.org/registry/organisation/a3c228d0-3110-11db-abb8-b8a03c50a862.json?op=contacts&callback=?", function(data) {
console.log(data);
});
Upvotes: 0
Reputation: 15675
If you are requesting the URL from a different schema/host/port combination (e.g. https://gbrds.gbif.com:8080
) your browser will throw a security exception because of a violateion of the same-origin policy
One way around this would be if you could implement jsonp which jquery also supports.
Upvotes: 0