jQuery Ajax scripts do not work on mobile browsers (any kind). It works on any kind of desktop browsers and in a their simulations of mobile. But when uploaded on production server and tried to execute from any mobile phone, it does not work.
Edit: I've tried to post whole piece of code so some obvious errors could easily be detected.
let check_mobile = false;
<?php if (isMobile) { ?>
check_mobile = true;
<?php } ?>
alert('ok');
$('.prod-img-wrap').each(function(ind) {
let imgs_scope = {},
front = $(this).find('.js-itm-hover-img-front'),
back = $(this).find('.js-itm-hover-img-back'),
img_front = front.attr('data-img'),
img_back = back.attr('data-img'),
id = front.attr('data-id');
imgs_scope[id] = {
'img_front': img_front,
'img_back' : img_back ? img_back : null,
};
setTimeout(function(){
$.ajax({
url: 'index.php?route=product/category/product_thumb_work',
type: 'get',
data: { ids_imgs: imgs_scope },
dataType: 'json',
success: function(json) {
front.attr('src', json[id]['img_front']).addClass('m');
back.attr('src', json[id]['img_back']).addClass('m');
if ($('.js-itm-hover').length > 5) {
if (ind === 5) {
filters_ajax();
<?php if (isMobile) { ?>
filters_mobile();
<?php } ?>
}
} else {
if (ind === 0) {
filters_ajax();
<?php if (isMobile) { ?>
filters_mobile();
<?php } ?>
}
}
}
});
}, ind * 300);
});
<?php if (isMobile) {}
Answer is the line above, - it contains isMobile
, which obviously had to be a constant
, if not a variable
, - turned out missed $
before isMobile
, just like any non-constant variable in PHP, - be careful to syntax.