The situation is this, there is an Ajax request for a php file. From which I get the data, I also need to send a variable from the id attribute to this php file. I tried using a substitution to url ( url: 'http://lab.local/php/info.php' + id_place) , also through data: {'param': id_place} , does not work ...
window.Market.Liner.prototype.next_handler = function(event) { var instance = event.data.instance var products_place = $(this).parent().parent() var liner_place = products_place.find('.liner-line .box.blocks') var id_place = liner_place.data('id') console.log('id_place: ', id_place) $.ajax({ type: 'get', url: 'http://lab.local/php/info.php', data: {param: id_place}, error: function(jqXHR, textStatus, errorThrown) { console.log('ОШИБКА') }, success: function(data, textStatus, jqXHR) { console.log('data ', data) if (!data) { return null } var liner_line = products_place.find('.liner-line') .append('<div class="box blocks" data-id="'+ next_id +'">' + '<iframe width="294" height="170"'+ 'src="https://www.youtube.com/embed/'+ data['data']['video_id'] +'" ' + 'frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""> '+ '</iframe>' + '</div>') var new_position = instance.calc_position(1) if (new_position != instance.position) { instance.set_position(new_position) instance.ui_apply_position() } } }) } Actually for what, in order to make id dynamical. When I click, I send the id, from the search in the php file we take the necessary one and then send the data to js.
<?php $string = file_get_contents('./data_php.json'); header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); $array = json_decode($string); // var_dump($array); $dam = $_GET['param'];//сюда передаем номер id foreach($array as $key => $value) { if ($key == $dam) { echo(json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } // var_dump(json_encode($value)); } ?>