$(window).on('load', function(){ $('body').on('click', 'tr', function() { var sourceUrl = $(this).attr('src'); $("#player").attr("src", sourceUrl); $('#player').trigger('play'); }); function show_result(data){ $("tbody > tr").remove(); $.each(data, function(i, station) { $('tbody').append(''+station['name']+''); }); } function search(query){ $.ajax({ method: "POST", url: 'http://www.radio-browser.info/webservice/json/stations/search', data: { name: query }, dataType: 'json', success: show_result }); }; $('form').submit(function() { var query = $('input').val(); search(query); return false; }); });