On response i got multiple items, i want to append every item in response on h2 class. My code simply loop every items in one class <h2 id="test">
this is my try:
$(function() {
var $test = $('#test').one();
$.ajax({
type: 'GET',
url: 'test.json',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(tests) {
<!-- <!-- console.log(gares) --> -->
$.each(tests, function(index, item) {
$tests.append('<h2>' + item[1] + '</h2>');
});
}
});
});
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script>
<h2 id="test"></h2>
<h2 id="test"></h2>