Skip to content

Instantly share code, notes, and snippets.

@peter279k
Last active November 21, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/87caa7806de433d8fde0 to your computer and use it in GitHub Desktop.
Save peter279k/87caa7806de433d8fde0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>ajax example</title>
<meta charset="utf-8" />
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
$(function() {
//$.getJSON("http://peter279k.com/xml_converter/xml_handler.php", result);
//same function
$.ajax({
url: "http://peter279k.com/xml_converter/xml_handler.php",
dataType: "json",
method: "GET",
success: result,
fail: failLoad
});
});
//callback function(success)
function result(result) {
var res = result["DataSet"]["diffgr:diffgram"]["NewDataSet"]["CASE_SUMMARY"];
for(var i=0;i<res.length;i++) {
$("#ajax-access").append("<p>" + res[i]["CaseTime"] + "</p>");
$("#ajax-access").append("<p>" + res[i]["CaseDescription"] + "</p>");
}
}
//callback function(fail)
function failLoad(err) {
console.log(err);
}
</script>
</head>
<body>
<h2>disaster</h2>
<div id="ajax-access"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment