Obtaining a list of Omeka Exhibits Using Javascript
I needed to obtain a list of Omeka Exhibits to display in a non-Omeka website. The following Javascript provided a list of the titles and descriptions.
<!DOCTYPE HTML>
<html>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
var json_obj = JSON.parse(Get('http://yoururl/api/exhibits/'));
for (i = 0; i < json_obj.length; i++) {
exhibit = json_obj[i];
document.write('<h3>' + exhibit.title + '</h3>');
document.write('<p>' + exhibit.description + '</p>' );
}
function Get(yourUrl){
var Httpreq = new XMLHttpRequest(); // a new request
Httpreq.open("GET",yourUrl,false);
Httpreq.send(null);
return Httpreq.responseText;
}
</script>
</body>
</html>
Page 2 of 2