The Ajax function fails to trigger in Phonegap when running on an Android device

I have been searching for similar questions but haven't found a satisfactory answer. I am developing an app for multiple platforms using PhoneGap and JQM. I created an index.html, which serves as the "login page", with a similar call. The call in the index works fine, but the one below is not being executed on my Android device, even though it works on both Chrome and Safari.

I have checked the server logs and there are no issues with the "login" function. However, there seems to be no request from my Android device when the function below should be triggered.

    //document.addEventListener("deviceready", onDeviceReady, true);

$( document ).bind( "mobileinit", function(){
        $.support.cors = true;
        $.mobile.allowCrossDomainPages = true;
        $.mobile.loadingMessageTextVisible = true; 
        $.mobile.showPageLoadingMsg();
        console.log('Page Started');
})

//var onDeviceReady = function(){

$( document ).ready(function (){
        console.log('Start');
        //$.support.cors = true;
        //$.mobile.allowCrossDomainPages = true;
        $.ajax({                                                                   
        crossDomain: true,
        type: 'GET',
        url: 'http://ip/services/rest/contact/list', 
        callback: 'jsonpCallback',
        jsonpCallback: 'jsonpCallback',
        jsonp: '_jsonp',
        contentType:  'application/json',
        dataType: 'jsonp json',
        timeout : 10000,

        success: function(data){

            var html ='';
            console.log('Success');
            $.each(data.response, function(key, value) {
            html += '<li><a class=contact href="#" id="' + data.response[key].id + '" ><h1>' + data.response[key].label + '</h1><p>'+ data.response[key].customerName + '</p><p>' + data.response[key].phone + ', ' + data.response[key].email + '</p></a></li>';
            $('#ul_id').append($(html));
            html='';
            console.log('conatct');
            });
            $('#ul_id').trigger('create');    
            $('#ul_id').listview('refresh');

        },
        error: function (xhr, ajaxOptions, thrownError){
            alert("Status: " + xhr.status + ", Ajax option: " + ajaxOptions + ", Thrown error: " + thrownError);
            //location.reload();
            console.log('Blad');
        },
    }); 
});

Answer №1

Can you provide the access origin setting from your Android project's config.xml file?

The expected format for the access origin value is:

<access origin=".*"/>

Answer №2

We encountered an issue trying to insert the script in a particular manner, affecting how jqm functions.

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

Can you combine multiple items in PaperJS to move them collectively?

I'm working on a PaperJS project that involves numerous circles that can move independently. In addition to this, I would like each circle to have PointText at its center acting as a label. However, instead of having to manually animate each label ev ...

What is the process for creating the LN (Log Natural) function?

I'm looking to create a math project that involves calculating Exponential regression using an LN (Log Natural) function in Android Studio. Can anyone provide guidance on how to implement this? ...

Obtain the HTML of a Vue component and transmit it using an ajax POST request

I need to send an email with an HTML body using only ajax since I don't have access to the server code. Fortunately, the server has an API for sending emails. Currently, I have a dynamically rendered component called invoiceEmail. sendEmail () { ...

Retrieve all the values from a form with identical names using angularjs

I have a form with two text boxes, one for entering a name and the other for an email. There is also a button to add a new row with these two text boxes. I am attempting to retrieve the values of Name and Email using AngularJS, but I am new to Angular. Be ...

Challenges encountered while trying to combine Vue 3 with Firestore

I am currently in the process of integrating Firebase (and Cloud Firestore) with my Vue 3 app. I have successfully installed the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="65030c170007041600255c4b554b57">[email prot ...

Exciting jQuery animations and transitions

Is there a way in JavaScript to call function or method names using a string? For example, when writing jQuery code that applies an effect to specific targets, can the effect be dynamic and changeable by the user? I'm hoping for something like jQuer ...

Tips for rearranging sibling divs while maintaining the order of their child elements

Is there a way to shuffle the order of div classes shuffledv, while maintaining the same order of id's each time the page is refreshed? <div class="shuffledv"> <div id="2"></div> <div id="3"></div> <div id="1">< ...

Ways to eliminate the worldwide model in SAPUI5

I've been attempting to break down the global model without success. I have a filter button that's set up like this: navToSecond : function (oEvent){ var oObject = this.getView().byId("inp").getValue(); sap.ui.getCore().setModel( ...

Challenges with Validating Bootstrap Datepicker Functionality

I need to restrict the datepicker input control to only allow selection of dates from the current date onwards. Despite trying to implement validation using the bootstrap-datepicker library and the following JavaScript code, I am still facing issues: $(& ...

Slicing an array in Javascript/Angular before it is officially initialized

Is it possible to specify the portion of an array to retrieve before making a $http GET request in Angular? I am aware of slicing arrays, but wondering if I can set this up in advance for better performance. In PHP, you can do something similar, but not ...

I keep encountering the following issue: "It seems that the file requested at /images/crown.png is not recognized as a valid image, as it was received as text/html; charset=utf-8."

I encountered an issue while utilizing Next.js. Here is the code snippet where the error occurred: import React from "react"; import { Container, Col, Row } from "react-bootstrap"; import Image from "next/image"; export defaul ...

The expiration and creation of access tokens in the Gmail API

For the past 6 months, I have been utilizing the Google API to send emails from my server in a Node.js project. I have successfully set up credentials and generated both refresh and access tokens, which I have been using consistently. oAuth2Client = new go ...

Tips for positioning the overlay to match the icon list when hovering- JavaScript/Cascading Style Sheets (CSS)

My challenge involves a list of <li>'s accompanied by an icon that, when hovered over, displays an overlay containing information about the 'test'. The setup looks something like this: test1 test2 test3 and so forth.... Here' ...

Is there a way to improve error readability in React when using webpack?

Attempting to solve the issue, I decided to make a change in my npm script. Initially, it was set to operate in production mode by default: The original script looked like this: "client": "webpack -w --config ./gen/config/webpack.config.js& ...

Managing user sessions for a mobile app login in PHP: Best practices

As a professional PHP programmer, my expertise lies in web development and I have limited knowledge about coding for iOS and Android platforms. Currently, I have created RESTful APIs for two mobile apps, one for iOS and the other for Android, which replic ...

Attempting to grasp the intricacies of HTML5/JS video playback quality

I've been diving deep into research on this topic, but I can't seem to find a straightforward answer to my specific query. My main focus is understanding the inner workings of how video players transition between different quality settings (480p, ...

Easy selector for choosing jquery css backgrounds

Here is a simple background selector that I created. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <hea ...

Modifying DialogFragment layouts on the fly

I am working on an Android project where I need to display a dialog from an Activity. The dialog will be a custom DialogFragment and I want the layout inside the dialog to change based on user interactions with specific buttons. Additionally, I want the di ...

Filtering custom posts in ACF by a specific subfield within a repeater group

I've been trying to implement the tutorials from the ACF documentation, but I'm having trouble getting it right. My setup includes Advanced Custom Fields and Custom Post Type UI plugins. Specifically, I have a custom post type called materials, ...

What causes certain images to have unspecified height and width measurements?

Currently, I am in the process of extracting image sizes from a website using a module called scraperjs. Most images have their height and width attributes defined, but some do not, resulting in the returned value being "undefined". How can I retrieve the ...