Last active
July 25, 2023 14:27
-
-
Save kjgarza/34ca6a866b4437bc1c07d84f208a01c4 to your computer and use it in GitHub Desktop.
JavaScript script to enable Content-Negotiation call for DataCite metadata in schema.org format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var identifier = "https://doi.org/10.5284/1015681"; //for example 10.5284/1015681 | |
if (identifier === undefined) { | |
return; | |
} | |
var doi = new URL(identifier); | |
var url = "https://data.crosscite.org"; | |
url += '/application/vnd.schemaorg.ld+json/' + doi.pathname; | |
$.ajax({ | |
url: url, | |
dataType: 'text', // don't convert JSON to Javascript object | |
success: function(data) { | |
$('<script>') | |
.attr('type', 'application/ld+json') | |
.text(data) | |
.appendTo('head'); | |
}, | |
error: function (error) { | |
console.log(error.responseJSON); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment