W
W
WebforSelf2020-04-18 21:14:49
JavaScript
WebforSelf, 2020-04-18 21:14:49

Why is the jquery script not executing?

Friends, when loading the site, I load the php file via Ajax in which the tpl file is loaded

<script async>document.addEventListener("DOMContentLoaded", function(event) { $.ajax({ url:'/ajax/cities.php', success: function(mes){ $('.footer1512-container').before(mes);}});});</script>


cities.php

<?
session_start();
  require_once('../api/Simpla.php');
  $simpla = new Simpla();
  $all_cities = $simpla->cities->all_cities();
  if( isset($_SERVER['HTTPS'] ) ) { 
  $simpla->design->assign('protocol',	'https://'); }
  else { $simpla->design->assign('protocol',	'http://');}
  $text = $_SERVER['HTTP_REFERER'];
  $array = explode("/",$text); // перерабатываем строку в массив
  $array = array_slice($array,3); // выбираем первые 5 слов-элементов
  $array = implode("/",$array);
  $domen=explode('.',$_SERVER['SERVER_NAME']);
  if(sizeof($domen)>2) {$domen=substr($_SERVER['SERVER_NAME'],strpos($_SERVER['SERVER_NAME'],'.')); preg_match("/[^\.\/]+\.[^\.\/]+$/", $domen, $matches); $domen = ".".$matches[sizeof($matches)-1];} else $domen = ".".$_SERVER['SERVER_NAME'];
  $simpla->design->assign('domen',	$domen);
  $simpla->design->assign('script',	$array);
  $simpla->design->assign('all_cities',  $all_cities);
  $result = $simpla->design->fetch('setcity.tpl');
  header("Content-type: application/json; charset=UTF-8");
  header("Content-Encoding: gzip");
  header("Cache-Control: must-revalidate");
  header("Pragma: cache");
  header("Expires: -1");	
  print gzencode(json_encode($result), 9);


it’s not worth delving into the essence of the code, but in the end we load the TPL in front of the basement block.

$result = $simpla->design->fetch('setcity.tpl');

Thus, further this tpl needs to be loaded by a pop-up window with this event on the button.

$().ready(function() {
        $('.city_frame').jqm({trigger: '.city_btn'}).addClass('show');
      });


But for some reason it doesn't work. How to make friends?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question