There is a jQuery AYAX request that loads the name of the template when the page loads.
var tmp_name = ''; $.ajax({ url: shopScript, type: 'POST', dataType: 'json', data: { action: 'get_tmp_name' }, success: function(data) { tmp_name = data.data.tmp; console.log(tmp_name);//Результат: russian console.log(window.tmp_name);//Результат: russian } }); console.log(tmp_name);// Результат: ''; console.log(window.tmp_name);// Результат: ''; And so the question is why in success does not overwrite the value of a global variable?