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!