I have searched and searched and can't figure out why this code wont load an XML element into the
. I'm trying to load the XML from a file, read for a specific element and put it's data into a specific element.
HTML:
<!DOCTYPE html>
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function(){
$.ajax({
type: "GET" ,
url: "score1.xml" ,
dataType: "xml" ,
success: function(xml) {
var xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc );
$home = $xml.find( "home" );
$( "#home" ).text( $home.text() );
}
});
});
</script>
</head>
<body><p id="home"></p>
</body>
</html>
score1.xml:
<?xml version="1.0" encoding="UTF-8"?><score><home>22</home></score>
(Should also add that while I've been using PHP/HTML for years, I am a total newbie to OOP and JQuery.)
successcallback and inspect thexmlvalue?