Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Cordova 10 unable to post ajax to http url

I'm trying to send json data to an http url without success (I tried to send same data to an other https with success). I have this settings: config.xml

<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

AndroidManifest.xml

android:usesCleartextTraffic="true"

HTML Header

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *;"> 
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *">

<script>
  $.ajax({
    type: "GET",
    url: url,
    dataType: "jsonp",
    jsonp: 'callback',
    crossDomain: true,
    async: true,
    data: {
      id: results.rows.item(i).id,
      bolla: results.rows.item(i).bolla,
      anno: results.rows.item(i).anno,
      magazzino: results.rows.item(i).magazzino,
      articolo: results.rows.item(i).articolo,
      quantita: results.rows.item(i).quantita,
      term: terminale
    },
    success: function (data) {
      console.log(data)
    },
    error: function (xhr, textStatus, err) {
      alert("readyState: " + xhr.readyState);
      alert("responseText: " + xhr.responseText);
      alert("status: " + xhr.status);
      alert("text status: " + textStatus);
      alert("error: " + err);
    }
  });
</script>

If I use json it returns devicereadystate=0 and error if I use jsonp it returns devicereadystate=4 and error 404 (the url is correct if I paste to a browser it works)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe this is because with cordova-android 10.0.x, the webview is now acting as a https page and you can't load/send to non secure origins while using https.

From the cordova docs

By default, the WebViewAssetLoader is enabled and allows apps to serve their content from a 'proper' origin. This will makes routing work easily for frameworks like Angular.

With no additional configurations, the app content is served from https://localhost/. You can configure the hostname by setting the preference option hostname.

   <preference name="hostname" value="localhost" />

The scheme, https, is not configurable by nature.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!