Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

Why javascript/jquery code does not work on n android devices?

On laravel 8.83 / jquery 3.6.0 app when user clicked on action button and ajax response returned new value is set (groupedNewsUserActionsCount of response) into div with id = "#total_actions_" + newsId + "_" + action + "_label" and to assign class 'news-user-reactions-item-voted' into block

I do it with a code :

$.ajax({
    type: "POST",
    dataType: "json",
    url: "/news/react",
    data: {"_token": "{{ csrf_token() }}", "newsId": newsId, "action": action},
    success: function (response) {

        $("#total_actions_" + newsId + "_" + action + "_label").html(response.groupedNewsUserActionsCount === 0 ? '' : response.groupedNewsUserActionsCount)

        // Make _cancel action button visible and hide add action button
        $("#a_" + newsId + "_" + action + "_add_action").css('display', 'none')

        $("#a_" + newsId + "_" + action + "_cancel_action").css('display', 'block')

        // User voted this action : show icon image in light blue color
        $("#div_" + newsId + "_" + action + "_add_action_block").attr('class', 'news-user-reactions-item-voted')
    },
    error: function (error) {
        console.log(error)
    }
});

That works ok on common browsers, but does not work properly(new value is not set and class is not changed) on android devices. Do I use some invalid methods which are not valid for android devices ? Which methods have I to use ?

0 likes
5 replies
Tray2's avatar

The probable reason is that you are using incompatble versions of android, browser, and jquery.

Older android and their default browser does not support ES6 or maybe not even ES5. Never versions of Android (10 ,and chrome 74) for example has support for ES6. So you need to check your Android version, your browser version and your jQuery version, to see if they all are compatible.

1 like
mstdmstd's avatar

@Tray2 Checking here https://caniuse.com/?search=jquery I see they are compatible. Also this site has a lot of jquery code and all the rest of the app works ok. Seems only this issue with changing html inner text and class name "on fly" dos not work properly.

mstdmstd's avatar

@Tray2 It works ok on all browsers in my kubunu 20.04. But I have this problem on my Samsung Galaxy A 50 and Galaxy A8 of my team-member. Also Please read my message below on my next search results...

mstdmstd's avatar

I make test with Samsung Galaxy A 50 and when my page is opened in chrome browser I found option/checkbox "Version for comp" - if to turn it on the the page is reopeened at first - and after that all functionality with new value applied and class changed new class changed WORKS properly! What option is it and how I use it in my issue ?

Please or to participate in this conversation.