Last active
November 21, 2015 15:19
-
-
Save peter279k/87caa7806de433d8fde0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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