When downloading content via AJAX, JS events do not work!
What should be done?

$("#target").change(function() { var gord_top_sd = $(this).val(); $('.ikon_gorser').show(); $.ajax({ type: "POST", url: "/handler/gorod_php.php", // Обработчик. data: "city=" + gord_top_sd, dataType: "text", success: function(response) { $('.target_gor').html(response); } }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select id="target" class="ui search dropdown" name="region"> <option value="">Поиск</option> <?php foreach ($city as $region=>$cityList) { echo '<option class=" oblast" value="' . $region . '">' . $region . '</option>' . "\n"; } ?> </select> <div class="target_gor"> <div class="ikon_gorser"> <div class="ui active centered inline loader"></div> </div> </div> 
  • one
    You need to add code to the question so that you can see what the problem is. But we can assume that 1) events need to be delegated, for example, using the on method in jQuery, or explicitly hanging them again after being added to the house - Grundy
  • and markup Html - Grundy
  • no need to add a snippet that doesn't work, just add as a code block - Grundy
  • and where at least one event is lost? - Grundy
  • The fact is that the AJAX handler loads content into the target_gor class, but JS does not apply to it! - Timon

0