Skip to content

Commit

Permalink
Update JS to handle json response
Browse files Browse the repository at this point in the history
  • Loading branch information
trymebytes committed Nov 29, 2024
1 parent 4add1cc commit 1e259a6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions assets/js/translation-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,21 @@
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.text();
return response.json();
})
.then(response => {
$(this).hide();
const $html = $(response);
const $html = $(response.data.html);
const $listItems = $html.find('li');
if ( 0 === response.data.nextPage ){
$(this).hide();
} else {
$(this).data('event-next-page', response.data.nextPage);
}
$(this).parent().prev('.wp-block-wporg-event-list').find('ul').append($listItems);
})
})
.catch(error => {
console.error('Error fetching next page:', error);
});

}
);

Expand Down

0 comments on commit 1e259a6

Please sign in to comment.