I'm trying to use jQuery to parse the DHS Threat Level that they have in their XML file, but I can't seem to get it to work. I'm very new with Javascript and non-presentational jQuery, so I'm probably missing something obvious.
This is the XML file:
<?xml version="1.0" encoding="UTF-8" ?>
<THREAT_ADVISORY CONDITION="ELEVATED" />
This is the Javascript I've written:
$(document).ready(function() {
$.ajax({
type : 'GET',
url : 'http://www.dhs.gov/dhspublic/getAdvisoryCondition',
dataType : 'xml',
success : function parseThreatLevel(xml) {
var threatLevel = $(xml).find('threat_advisory').attr('condition');
$('#nationalThreatLevel').append(threatLevel);
}
});
});
Below is the HTML I'm trying to use. Thanks in advance for any help or advice!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<script type='text/javascript' src='lib/parseThreatLevel.js'></script>
<title>National Threat Level</title>
</head>
<body>
<div id='nationalThreatLevel'></div>
</body>
</html>