The content on this wiki is being preserved for historical purposes, but is not being maintained and is probably no longer accurate.
For current information about DPLA Development, see the Development Portal
For latest API documentation, see the API documentation
Code snippets
From DPLA Dev Wiki
JSONP
JSONP can be used to sidestep the same origin rule enforced by most browsers.
If you're using jQuery, you might do something like this
<html>
<head>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script>
$(document).ready(function() {
$.ajax({
url: "http://api.dp.la/dev/item/?",
dataType: 'jsonp',
success: function(data){
$.each(data.docs, function(i,item){
var element = item.subject;
var container = '<br>' + element + '<br>';
$(container).appendTo('#results');
})
}
});
});
</script>
</head>
<body>
<div id="results">results</div>
</body>
</html>