I have got stuck in seemingly basic thing. My question is why is the simple html command not appending to the div?
Here is my XML Data:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<collection>
<ErrorOps>
<aErrorID>53f4760f2af5422ac99af750</aErrorID>
<bErrorName>RMOB RULE_INFO_2</bErrorName>
<cErrorCause>Database Out Of Sync</cErrorCause>
<dErrorResolution>Try clearing your cache, or check database ver</dErrorResolution>
<eErrorTD>{ "Java Null ??" : 203 , "Java File ??" : 102}</eErrorTD>
</ErrorOps>
<ErrorOps>
<aErrorID>53f4760f2af5422ac99af751</aErrorID>
<bErrorName>ERROR X_2609</bErrorName>
<cErrorCause>CAUSE X_2609</cErrorCause>
<dErrorResolution>PERFORM X_2609</dErrorResolution>
<eErrorTD>{ "Java X_2609_1" : 203 , "Java X_2609_2" : 102}</eErrorTD>
</ErrorOps>
<ErrorOps>
<aErrorID>53f476f32af54609aefcd02a</aErrorID>
<bErrorName>ERROR TR_1156</bErrorName>
<cErrorCause>CAUSE TR_1156</cErrorCause>
<dErrorResolution>RESOLUTION TR_1156</dErrorResolution>
<eErrorTD>{ "Java F_1345_1" : 267 , "Java F_1345_2" : 982}</eErrorTD>
</ErrorOps>
<ErrorOps>
<aErrorID>53f4760f2af5422ac99af752</aErrorID>
<bErrorName>ERROR Y_2609</bErrorName>
<cErrorCause>CAUSE Y_2609</cErrorCause>
<dErrorResolution>PERFORM Y_2609</dErrorResolution>
<eErrorTD>{ "Java Y_2609_1" : 203 , "Java Y_2609_2" : 102}</eErrorTD>
</ErrorOps>
</collection>
And here is my HTML code:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#car').click(function() {
$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
success: function (data) {
$('#content').empty();
$(data).find('ErrorOps').each(function(){
//var html = '<p> Sample Text </p>';
$('#content').append("<p>Text</p>");
}
});
},
cache: false
});
return false;
});
});
</script>
</head>
<body>
<a href="#" id="car">Car</a>
<div id="content">
</div>
</body>
</html>
Can anybody please tell me what is the problem? I think Text should get appended 4 times.