Android 9 encounters an error when processing a POST request in a hybrid app developed with JavaScript, Cordova, and PhoneGap

I am facing an issue with AJAX in my Android app (JS / CORDOVA). The code I am using is as follows:

$.post("http://mydomain.com.br/getInfos.php" {
    id: id
}, function(json) {
   if (json == "success") {
     alert("Success!");
   } else {
     alert("Error: " + json);
 }
});

The error response received is:

{“readyState”:0,“responseText”:“”,“status”:0,“statusText”:“error”}

Interestingly, the code works perfectly on Android versions 8 and below...

Any ideas on what could be causing this issue?

Answer №1

To enable the use of non-secure origins, you have the option to either utilize the plugin cordova plugin add cleartext or make modifications to config.xml by specifying android:usesCleartextTraffic. For more information on this issue, refer to the following link: Android 8: Cleartext HTTP traffic not permitted

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 layout of an Angular Material page gets disrupted when a sticky "header" with md-select options is used in combination with the md-backdrop

I designed a filter bar for a table that sticks above the table at a certain height. Everything was working smoothly until I opened the dropdown options in the md-select. This caused the md-backdrop to appear and apply inline positioning to the body, shift ...

Issue with display of animation on MUI TextField

I'm facing an issue with my TextField component. I have a placeholder and value set up, but when I insert an icon using the InputProps prop, the animation that normally changes from placeholder to value doesn't appear. However, if I remove InputP ...

Tips for concealing the Bottom bar action in React Native

Currently facing an issue with React Native - I need to hide the bottom action bar located just below my tab bar navigation. I'm trying to create a clone of the Disney + App and this particular problem has me stuck: Here's the bottom part of my ...

When creating nested objects, the defineproperty function on the object prototype does not trigger

Exploring and experimenting to unravel the workings of this feature, but I find myself puzzled by this particular scenario. Object.defineProperty(Object.prototype, 'a', {set: function() {console.log("Set!");} }); Based on my understanding, when ...

Getting rid of the title bar in Android

Similar Question: What changes are needed in a layout to hide the titlebar? How can I eliminate the title appearing beneath the battery and time indicator bar? I am not sure what to call that specific bar, but it's the "Nested XML Layout" bar in ...

Updating the total of textboxes using jQuery

I'm working on a jQuery function that totals the values of 7 textboxes and displays the result in a grand total textbox: $(document).ready(function() { $('.class2').keyup(function() { var sum = 0; $('.class2').each(funct ...

Troubleshooting HTTP Issues in Angular 2

I am currently facing an issue with my Angular 2 project's Http functionality. I have defined it as a parameter in the constructor, but it keeps printing as undefined. Below is the snippet of code from my project: import 'rxjs/add/operator/toPro ...

Is there a way for me to achieve a vertical page turning effect on a single page?

I am seeking to develop a unique calendar display consisting of 12 images that give the illusion of flipping up when clicked. While I am aware of turn.js, my knowledge of javascript is limited and I need guidance on how to proceed. Despite having a program ...

Detecting collisions using CSS animation

I'm currently working on a unique "game" project. Check out the code snippet here: jsfiddle function update() { coyote.applyForce(gravity); coyote.edges(); coyote.update(); cactus.update(); if (coyote.intersects(cactus)){ alert("colisio ...

working with a list of Python objects in a JavaScript environment

Currently, I am building a web application using Flask and Python. In my Python code, I have a class that can be parsed as JSON. class uItem: itemCount = 0 def __init__(self, id, name): self.id = id self.name = name I am trying to acce ...

retrieving the current value of a variable from a jQuery function

I've done my best to keep things simple. Here's the HTML code I've put together: <div id="outsideCounter"><p></p></div> <div id="clickToAdd"><p>Click me</p></div> <div id="in ...

What is the best way to toggle a specific div element within an ng-repeat loop?

I have a list of products. When I click on a product, it should be added to the database. If I click on the same product again, it should be removed from the database. I am toggling the wishlistFlag using ng-click. This works correctly for one div element, ...

Using jQuery to manipulate XML: Altering XML content using its ID with jQuery

Trying to modify content within an XML using jQuery has been a bit tricky for me. Based on the examples I've found, I believe the code should look something like this: Javascript: get_verrichtingen: function(){ var self = this; var option = ...

Using React to pass a value through state when handling changes

Trying to implement handleChange and handleSubmit methods for a login page in React. Set username and password values in state, update them when form inputs change, then submit using the updated values. However, values print as undefined in the console. N ...

Looking for a way to update template variables in copy using grunt?

I am currently utilizing load-grunt-config along with grunt-contrib-copy. My objective is to have the copy task replace certain template tags using the 'process' option. I understand that replacing template tags is feasible based on the grunt-co ...

"Realm encountered an IllegalStateException due to a validation failure in the schema

I'm currently integrating the Realm Database into my project. Below are some snippets of my code: Application java code public class CoreApplication extends Application { private static CoreApplication sInstance; public static final String F_PREFE ...

Is it possible to compile a TypeScript file with webpack independently of a Vue application?

In my Vue 3 + Typescript app, using `npm run build` compiles the app into the `dist` folder for deployment. I have a web worker typescript file that I want to compile separately so it ends up in the root of the `dist` folder as `worker.js`. Here's wha ...

Resolving DataTables Error

Here is my JavaScript code snippet. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css"> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.2.1/css/but ...

Exploring jQuery's class attribute: Uncovering the key-value pair trick

I am encountering difficulties in obtaining the class of my div elements, which are intended to function as tabs on a simple asp.net website. I aim to achieve this using jQuery for better control over dynamic functions in the future. However, every time I ...

Set a maximum limit for the number of checkboxes that can be selected

If there are 10 checkboxes on a page, I am searching for a specific behavior: Use a variable called maxSelections to control the maximum number of selectable checkboxes Once maxSelections is reached, disable the other checkboxes on the page Even after re ...