jQuery Ajax脚本在移动浏览器上不起作用(任何类型)

jQuery Ajax脚本在移动浏览器上不起作用(任何类型),jquery,ajax,mobile-browser,Jquery,Ajax,Mobile Browser,jqueryajax脚本在移动浏览器(任何类型)上都不起作用。它可以在任何一种桌面浏览器上工作,也可以在模拟移动设备的环境中工作。但当上传到生产服务器并试图从任何手机执行时,它都不起作用 let check_mobile = false; <?php if (isMobile) { ?> check_mobile = true; <?php } ?> alert('ok'); $('.prod-img-wrap').each(function(ind) {

jqueryajax脚本在移动浏览器(任何类型)上都不起作用。它可以在任何一种桌面浏览器上工作,也可以在模拟移动设备的环境中工作。但当上传到生产服务器并试图从任何手机执行时,它都不起作用

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);


});
让check\u mobile=false;
检查_mobile=true;
警报(“正常”);
$('.prod img wrap')。每个(函数(ind){
让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_范围[id]={
“img_front”:img_front,
“img_back”:img_back?img_back:null,
};
setTimeout(函数(){
$.ajax({
url:'index.php?route=product/category/product\u thumb\u work',
键入:“get”,
数据:{ids\u imgs:imgs\u scope},
数据类型:“json”,
成功:函数(json){
attr('src',json[id]['img_front']).addClass('m');
back.attr('src',json[id]['img_back']).addClass('m');
如果($('.js itm hover')。长度>5){
如果(ind==5){
过滤器_ajax();
过滤器_mobile();
}
}否则{
如果(ind==0){
过滤器_ajax();
过滤器_mobile();
}
}
}
});
},ind*300);
});

jQuery Ajax在移动浏览器(我测试过的任何浏览器)上都能工作。您的问题必须在其他地方,如CSP或您的实现。您应该首先在Ajax中添加一个错误函数,这样您就可以在这里分享您遇到的错误。问题可能出在
let
?我知道不是每个浏览器都支持这一点。如果是这样的话,只需将其更改为
var
就可以了。smth-like-error:function(){alert('error');},根本不会触发。不,这绝对不是一个问题。您应该首先更新不推荐的jquery ajax语法(done/fail/始终替换success/error/complete)。这可能不是罪人,但你永远不知道。。