I have a ajax code that is
<script>
function myFunction() {
$("#dvContent").append("<ul></ul>");
$.ajax({
type: "GET",
url: "test.xml",
dataType: "xml",
success: function(xml){
$(xml).find('record').each(function(){
var sTitle = $(this).find('datafield[tag="245"]').find('subfield[code="a"]').text();
var sAuthor = $(this).find('datafield[tag="100"]').find('subfield[code="a"]').text();
var sIsbn = $(this).find('datafield[tag="020"]').find('subfield[code="a"]').text();
$.getJSON('https://www.googleapis.com/books/v1/volumes?q=isbn:0545010225', function(data) {
var text = `${data.items[0].volumeInfo.imageLinks.thumbnail}`
var x = document.createElement("IMG");
x.setAttribute("src", text);
document.body.appendChild(x);
$(".mypanel").html(text);
});
$("<li></li>").html(sTitle).appendTo("#dvContent ul");
$("<li></li>").html(sAuthor).appendTo("#dvContent ul");
$("<li></li>").html(sIsbn).appendTo("#dvContent ul");
});
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
}
</script>
Now i want to to fetch the values from a link rather than from a local file , in my case test.xml
.
i have tried putting
url: "http://lx2.loc.gov:210/lcdb?operation=searchRetrieve&recordSchema=marcxml&version=1.1&maximumRecords=10&query=bath.isbn%3D0545010225"
But then my code stops working . Any help regarding this will be highly appreciated.
EDIT 1: I googled around a bit and i've realized it's a cross domain issue.