I'm trying to retrieve the urls which are saved in all divs with the class "doi" under the data-value property by using the .each() function and pass it to a ajax call, so i can retrieve the specific data from the api and pass it as a string to specific div again.
Now i guess my problem here is, that the this pointer isn't working inside the ajax call. The answer might be quite simple i guess but i somehow can't figure it out.
jQuery(document).ready(function($) {
$(".doi").each(function() {
var doi = $(this).attr("data-value");
$.ajax({
headers: {
Accept: "application/vnd.citationstyles.csl+json"
},
type: "GET",
async: false,
url: doi,
success: function(data) {
if (data) {
$(this).text(JSON.stringify(data["is-referenced-by-count"]));
//$(".doi").text(JSON.stringify(data["is-referenced-by-count"]));
} else {
$(this).text("no result...");
}
},
error: function(jqXHR, textStatus, errorThrown) {
$(this).text("error: " + textStatus);
}
});
});
});