每个Ajax JSON

Hello guys i had a simple ajax request this also is working fine, but i had to loop trought the data and display all 10 names in the object allready searched it in stack but the object which i had is a bit to complicated. any suggestions how i can solve it?

$( document ).ready(function() {
$.ajax({
   url: 'XXXXXXX',
   data: {
      format: 'json'
   },
   error: function() {
   alert('ERROR');
   },
   sasdataType: 'json',
   success: function(data) {
    /*var $hotelname = $('<h1>').text(data.result.hotel[0].displayname);
        $('#hotel-name').append($hotelname)*/
    console.log(data);
   },
   type: 'GET'
});
});

If I figured the structure OK, it should be something like:

$.each(data.result.district, function(index, district) {
     $.each($(district), function(index, hotel) {
         console.log($(hotel).displayname);
     });
});

$(document).ready(function() {
  $.ajax({
    url: 'XXX',
    data: {
      format: 'json'
    },
    error: function() {
      alert('ERROR');
    },
    sasdataType: 'json',
    success: function(data) {
      $.each(data.result.hotel, function(index, value) {
        $('#hotel-name').append($('<h1>').text(value.displayname));
      });
    },
    type: 'GET'
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='hotel-name'></div>

You cane directly loop through hotel to get the hotel names as below using $.each

$.each(data.result.hotel, function(index, value) {
  console.log(value.displayname);
});
</div>

hope this is helpful for you

$.ajax({
   url: 'https://www.hrs.de/hotel/service/mmsuggest-group?query=k%C3%B6ln&language=de',
   data: {
      format: 'json'
   },
   error: function() {
   alert('ERROR');
   },
   sasdataType: 'json',
   success: function(data) {
    /*var $hotelname = $('<h1>').text(data.result.hotel[0].displayname);
        $('#hotel-name').append($hotelname)*/
    console.log(data);
  console.log(data.result);
data.result.hotel.forEach(function(hd){console.log(hd.displayname)});
   },
   type: 'GET'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

</div>