$(window).on("load", function() { var queryString = window.location.search; var urlParams = new URLSearchParams(queryString); var qValue = urlParams.get('q'); var myElement = $('#searchinput'); myElement.val(qValue); var strongElement = $('#searchtextstrong'); strongElement.text(qValue); $.ajax({ url: 'http://192.168.1.219:6431/api/v1/search', // The URL to send the request to type: 'GET', // HTTP method (GET, POST, etc.) dataType: 'json', // Expected data format from the server success: function(response) { // This function is called if the request is successful console.log('Data received:', response); $.each(response['activities'], function(key, value) { console.error(key, value); var resultHTML = `
` + value['content'] + `
` + value['published'] +`
`; $(resultHTML).appendTo('#result_container'); }); }, error: function(xhr, status, error) { // This function is called if the request fails console.error('Error:', error); } }); });