App.request on php script always return status 0

It’s my first time using framework7.

I’m trying to implement app.request on my app with the following code:

$$('#testButton').on('click', function (e) {

      alert("button click!");
      
      let params = {
        "duration": 30
      };

      let request_url = "http://192.168.0.100/wifree/omada/test.php";

      app.request({
          url: request_url,
          method: 'POST',
          dataType: 'json', //html or json
          data: params,
          crossDomain: true,
          headers: {
            'Access-Control-Allow-Origin' : '*'
          },
          success: function(data) {

            alert("success");
            alert(JSON.stringify(data));
            //return callback(data);

          },
          error: function (xhr, status, message) {

            alert("Error request");
            alert(JSON.stringify(xhr));
            alert(status);
            alert(JSON.stringify(message));

          },
          complete: function(xhr, status) {

            //alert("Complete request");
            //alert(JSON.stringify(xhr));
            //alert(status);

          }

      });

    });

This is my PHP Script:
<?php
ini_set(‘max_execution_time’, 300);
header(“Access-Control-Allow-Origin: *”);
$resp = array(
‘result_count’ => $_POST[‘duration’],
‘data’ => array(
‘id’ => ‘’,
‘date’ => ‘’,
‘voucher’ => ‘’
),
);

This works well on browser and getting success/response. However, I’m getting error status 0 when building the APK to Android phone. Could anyone experience this? Any help will be appreciated.

Much thanks!

Have you already inspected your app with the Chrome device inspector? Maybe the console or XHR request viewer can give you some clue about what’s going wrong.

Hi Tim,

Thank you for helping me. I tried the Chrome device inspector, but it just shows me a request from index.html, nothing more. I can’t see the app request to my php file. Am I missing something?

To anyone who may experience this issue. I’ve found out why (Thanks Tim for pointing me to use the Chrome device inspector). It turns out that I’m getting ERR_CLEARTEXT_NOT_PERMITTED, the the solution reference is here: https://stackoverflow.com/questions/54752716/why-am-i-seeing-neterr-cleartext-not-permitted-errors-after-upgrading-to-cordo