While Ajax POST is functional on desktop, it does not seem to work on Phonegap applications or Android

I am facing an issue with a global function that does not seem to work properly in the PhoneGap Desktop app or Chrome Mobile on Android. Surprisingly, it works perfectly fine only in the Chrome PC version. The function is called using an onClick event, and it involves a switch checkbox SVG element with the ID #suich.

function setPush() {
    var nick_ = window.localStorage.getItem("username");
    var notify = window.localStorage.getItem("option");
    $.ajax({
        type: "POST",
        url: "push_set.php",
        data: ({
            nick: nick_,
            opcion: notify
        }),
        cache: false,
        dataType: "json",
        success: function(data) {
            if (data.status == 'success') {
                if (notify == 1) {
                    myApp.alert('Notifications disabled', 'Notice:');
                    $('#suich').prop('checked', false);
                } else {
                    myApp.alert('Notifications enabled', 'Notice:');
                    $('#suich').prop('checked', true);
                }
            } else if (data.status == 'error')
                alert('Connection problems', 'Warning:');
        }
    });
};              

Answer №1

Consider using the complete URL rather than

url: "push_set.php"

such as

url: "www.mywebsite.com/push_set.php"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The malfunctioning jQuery dropdown menu on hover that needs fixing

Currently, I have an HTML link that utilizes the hover() function (specifically using the hoverIntent plugin) to prompt a div to slide down by animating the CSS top attribute. Everything is functioning as expected, except when the cursor transitions from ...

Dynamic JavaScript button control based on time

I am currently working on an app and my goal is to have a feature where the user clicks a button, it will then disappear and only reappear after 24 hours. Here's my progress so far. <div class="buttons"> <p><button onclick="hide(); ...

Troubleshooting Problems with Magento's Cart Ajax Feature

I have successfully implemented an Ajax-based button on the product listing page to add products. However, I am facing issues with updating the cart displayed at the top of the page. I need assistance in updating the cart as well. The cart PHTML file can ...

The `encodeAddress()` function in Google Geocode is used to ge

Encountering issues with extracting latitude and longitude values from Google's response. Google is providing XML-like data: "location" : { "lat" : 53.55914120, "lng" : 10.00923520 }, I am trying to parse this using var r = results[0].geome ...

EJS include function not working properly

In most cases, my EJS pages include the code below: <%- include('elements/fbviewpagepixel.ejs') %> Everything runs smoothly except for one particular page where I encountered an error message stating include is not a function. I managed t ...

Tips for Adding Items to an Infinite Loop

Could you please review This Demo and advise me on how to continuously load items into the ul list in an endless manner? Currently, I have this code set up to display the list but I want it to keep adding new items to the end every time. var item = $(". ...

How can HTML text be highlighted even when it's behind a transparent div?

In my React application, I am facing an issue with a transparent div that serves as a dropzone for draggable elements. This div covers text and also contains children elements that may have their own text content. <Dropzone> <SomeChild> . ...

Establishing a simple communication channel between two fragment instances and assigning unique identifiers to each fragment within the

In the MainActivity of my app, I have implemented two fragments that were created in the XML layout file. I am facing a challenge when trying to pass user input from Fragment A to Fragment B's text view. Can anyone provide guidance on how I can achiev ...

"Trouble with making jQuery AJAX calls on Internet Explorer versions 8 and 9

I've been searching for the answer to this problem without any luck. I have a page with jquery ajax calls to an API service. It works well in Chrome, Safari, Firefox, and IE 10, but fails in IE 9 and 8. Here is the code: $.ajax({ ...

Order Up: Vue Draggable Next feature keeps your lists in line

I need to maintain the order of two lists in local storage so that their positions are saved and retrieved between sessions. In my Vue 3 TS project, I am utilizing this library. Check out the code snippet below: <template> <div> <h3> ...

Learn how to toggle multiple class elements with jQuery, and how to hide the ones that have

This is an example of my HTML code: <h4 class="list-group-item-heading"> @Model.Customer.FirstName @Model.Customer.LastName wrote: <span class="right"><span class="icon-file padding-right link"></span></span> </h4& ...

The multiple-choice selection tool is not displaying any choices

I am having an issue with my ng-repeat code in conjunction with the jquery multiple-select plugin. Despite using this plugin for a multiple select functionality, the options generated by ng-repeat are not visible. Below is the code snippet in question: & ...

Unlocking Iframe Mode in CKEditor 4

I've encountered a difference between CKEditor 3 and CKEditor 4. In CKEditor 3, when I call the method CKEDITOR.replace('#textAreaId'), it wraps the editor in an iframe. However, in CKEditor 4, when I call the same method (not inline), the i ...

What is the best method to reset values in ngx-bootstrap date picker?

At the moment, it is only accepting the most recently selected values. To see a live demo, click here. ...

"Every time I try to run an app using Flutter, I encounter error messages

Just recently I installed Flutter, but every time I try to run a Flutter app, I encounter this error message: FAILURE: Build failed with an exception. * Where: Script '/Users/ashvinbhagat/development/flutter/packages/flutter_tools/gradle/flutter.gra ...

Updating Message for No Results in DataTables using JSON Response or another DataTables Parameter

In a certain context, I have developed an application using DataTables that makes use of the default search functions and performs excellently. However, there are additional filters and permission constraints in place that determine what is shown on the pa ...

Transform the size and convert an object from a picture into text based on the user's scrolling

I've been intrigued by the scrolling effects used on websites like Google SketchUp and Google Plus. It's fascinating how elements can transform as you scroll down the page. For example, on Google SketchUp's site, the banner starts off integr ...

Why isn't my Angular directive able to access the parent controller's scope within its isolated scope?

I have meticulously followed the Angular documentation to implement a directive with an isolated scope that contains a few variables from the parent Controller's scope object. app.controller('MainCtrl', function($scope) { $scope.name = ...

Using AngularJS to filter JSON data

Greetings! I possess the following JSON data: $scope.Facilities= [ { Name: "-Select-", Value: 0, RegionNumber: 0 }, { Name: "Facility1", Value: 1, RegionNumber: 1 }, { Name: ...

Is there a CSS3 Selector With Similar Functionality to jQuery's .click()?

For a few years now, I have been utilizing a pure CSS navigation system. However, with the recent increase in mobile site projects at my workplace, I am encountering issues with drop-down menus not functioning properly on mobile devices. Despite this chall ...