Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Why javascript/jquery code does not work on 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 :

JavaScript:
$.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 ?


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 ?
 
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 :

JavaScript:
$.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 ?


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 ?
Might just be a caching issue. Clear your phone's browser cache and try it again
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom