Exploring the world of Ajax requests within Android phonegap applications

Initially, my project using Dojo worked flawlessly with PhoneGap 2.7.0. However, upon upgrading to PhoneGap 3.0, none of the ajax requests appear to be going through.

To rule out Dojo as a factor, I created a basic test page using plain JavaScript, but unfortunately encountered the same issue.

Sincerely, Mike

My current setup:

  1. PhoneGap 3.0
  2. Android 4.1.1 on Galaxy S3, or Android 4.3 on emulator
  3. The < uses-permission android:name="android.permission.INTERNET" /> is included in the manifest
  4. < access origin="*" /> is specified in the config.xml

JavaScript logic:

    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange=function(){
      alert ("rdystate: " + xmlhttp.readyState);
      alert ("status: "   + xmlhttp.status);
      alert ("Text: "     + xmlhttp.statusText);
      alert ("ResponseText: " + xmlhttp.responseText);
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
      {
        alert(xmlhttp.responseText);
      }
    }
    xmlhttp.open("GET","http://10.0.2.2:8080/myapp/rest/feedback/ping",true);
    xmlhttp.send();

Output:

    rdystate: 1
    rdystate: 2
    status: 404
    Text: *empty*
    ResponseText: *empty*
    rdystate: 4
    status: 404
    Text: *empty*
    ResponseText: *empty*

Answer №1

There may be some uncertainty, but my understanding is that utilizing IP addresses might not be included in the domain whitelist. Have you considered directing a DNS record to it and attempting to use the domain name instead?

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

Is there a way to establish a secure database login using the user generated in Cpanel?

Currently, I am in the process of developing an Android application and utilizing PHP scripts for handling all my requests. As I am relatively new to this field, I am seeking guidance from you all. Typically, when establishing a connection to a database us ...

Exploring AngularJS to search for and present data in a tabular layout

Can anyone guide me on searching for data within a JSON file and presenting it in a table format? I want the table to be visible only when I click the search button. I would really appreciate it if someone could provide me with instructions or a helpful ...

Issue with AngularJS: Controller unable to access property of ng-model object

I am looking to create a reusable controller that can be used by multiple views. This controller will essentially serve as a template. The issue I'm facing is with setting up simple validation. The problem lies in the fact that the properties set in ...

Should we define all public methods or prototype each method separately?

Typically, when I create a library, my approach is as follows: var myLibrary = (function() { return { publicProperty: 'test', publicMethod: function() { console.log('public function'); }, ...

Concatenating two digits in JavaScript while preserving their integer properties can be achieved by converting

I am looking to combine two numbers while preserving their integer format, instead of converting them to characters. var a = 100; var b = 10; var c = Number("" + a + b); return c; '10010' is in character format, but I need it in integer format. ...

Obtain an array as the response from an Ajax call

When passing data using Ajax request, I utilize the code below: var query = { "username" : $('#username').val(), "email" : $('#email').val(), } $.ajax({ type : "POST", url : "system/process_registration.php", ...

The $scope in Angular doesn't seem to be working as expected in the callback function, despite using $scope

I'm currently working on converting the JSFiddle found here to AngularJS: http://jsfiddle.net/danlec/nNesx/ Here is my attempt in JSFiddle: http://jsfiddle.net/leighboone/U3pVM/11279/ var onAuthorize = function () { updateLoggedIn(); $scope. ...

Merge similar elements in an array by a specific property

I am looking to create a new array that combines values of repeated campaigns let arrayName = [ { campaign: "a", value: 3 }, { campaign: "b", value: 5 }, { campaign: "c", value: 7 }, { campaign: "a", value: 9 }, ]; EXPECTED OUTPUT: [ { campaign: ...

display dynamic graphs using json data from a php backend

I'm having trouble displaying a graph using JSON data in Highcharts. Here is a sample of what I need: http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/column-rotated-labels/ The file values ...

Troubleshooting: My Angular 2 Application is Unable to Perform HTTP

I've exhausted all options and I'm still unable to send an http request to my node server on heroku. I can access the route manually, so it's not an issue with the server. Below are snippets of my service and page: **Class is subscription.s ...

Trouble arises when adding a .js script to the webpage

I'm feeling quite puzzled by this small piece of code, as it appears to be the simplest thing you'll come across today. Despite that, I can't help but seek guidance because I've been staring at it for what feels like an eternity and can ...

What is the process for incorporating a Bootstrap link into a specific ReactJS file?

In my current project using React JS, I found the need to incorporate Bootstrap in certain pages. To do this, I initially placed the following code snippet in the Public folder within index.html: <link rel="stylesheet" href="https://netdna.bootstrapc ...

Processing JSON data from an array in PHP

Currently, my code involves utilizing an AJAX request to retrieve data from a database dynamically. The data received is processed by the PHP function json_encode() before being sent back to AJAX. Upon receiving the data through the AJAX request, it is for ...

Transferring data from a React file to a plain HTML page

What is the best way to transfer information from a React app to a static HTML file? For instance, if I collect data through a form in a React app.js file, how can I then send that data to a basic HTML file? ...

Inserting an item into a list

Looking for assistance with this particular scenario: { "EekvB3cnwEzE":{ "name":"hi", }, "Brv1R4C6bZnD":{ "name":"yup", }, "kRwRXju6ALJZ":{ "name":"okay", } } I'm attempting to store each of these objects in an array. Howe ...

What are the steps for creating a dropdown menu that allows for easy selection of the correct item

I am dealing with a dropdown menu as shown below. <select name="slt"> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> <option value="3">Three +</option&g ...

Encountering memory leaks and displaying repetitive data due to having two distinct observables connected to the same Firestore

I am currently utilizing @angular/fire to retrieve data from firestore. I have two components - one serving as the parent and the other as the child. Both of these components are subscribing to different observables using async pipes, although they are bas ...

Utilizing command handlers for economy commands in Discord.js

Recently, I’ve been diving into creating my very first economy system and command handler. So far, I've successfully integrated the '-balance' command with the command handler. However, I'm facing a challenge in integrating other comm ...

Guide to successfully navigating to a webpage using page.link when the link does not have an id, but is designated by a

This is my current code snippet: async function main(){ for(int=0;int<50;int++){ const allLinks = await getLinks(); //console.log(allLinks); const browser = await puppeteer.launch({ headless: true }); const page = await browser.newPa ...

Unable to render any charts with angular-chart.js

Utilizing the dependency angular-chart.js in my angular project has allowed me to showcase data visualizations on my admin page. Recently, I decided to upgrade angular-chart.js to version 1.1 and Chart.hs to version 2.5 based on the README.md guidelines o ...