I'm trying to set up a backup system that will run off an Android tablet in a disconnected environment. To do this, I installed a server on the tablet and a WIFI hotspot. These appear to be working as expected, but do complicate this question, because replicating the issue gets dicey.
I took a PHP script that I borrowed and modified. The key part of the script is this:
The point is that there is a default response created with data = Null. I then check the POST['action'] and return something slightly more whimsical. If the If fails, then the response is set to 'Not Much'. This allows me to see three different outcomes:
1) The If wasn't reached.
2) The If was reached, and was True.
3) The If was reached, and was False.
I put this php file into the right folder on the tablet, navigated to the file with my browser, which means a URL that looks like this, in this case:
http://192.168.1.110:8080/snorkel/index.php
and got back a response that showed option #3, so the file was working fine. I hadn't supplied an action, so option #2 was out of the question, which is fine. The point is that the file is working fine on the tablet and is accessible from the test computer.
Then, in the main program, which is a large JS/JQuery web app, I tested that the web application was able to reach outwards from the test environment by hitting a service on a different computer to update some tables. This worked as desired (well, actually one of the tables had an issue, but that's a different matter for me to investigate, but the other tables worked fine).
The final step was to test out the backup, which meant hitting that php page. I have tried various versions of this and have always gotten a really opaque result, which is why I'm asking here. The JQuery code for the call looks is this:
I have checked that the URL passed in tURL is exactly as I posted earlier. The value in data doesn't seem to have any impact at all, since anything I pass has the same result.
I then put a breakpoint inside the success and error methods. In all cases, I reach the error method. TextStatus shows 'error', and errorThrown is ''. I haven't been able to get any other result.
Originally, I tried this with a Get call rather than post, but there's never an answer. So, directly accessing the index.php file via a browser shows that it's there and responding as expected, but I have been unable to get anywhere with the JQuery approach.
Any help would be appreciated.
I took a PHP script that I borrowed and modified. The key part of the script is this:
Code:
// Set default HTTP response of 'ok'
$response['code'] = 0;
$response['status'] = 404;
$response['data'] = NULL;
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
$response['code'] = 1;
$response['status'] = $api_response_code[ $response['code'] ]['HTTP Response'];
$response['data'] = 'Sofa so good';
}
else{
$response['data'] = 'Not Much';
}
// Return Response to browser
deliver_response($response);
1) The If wasn't reached.
2) The If was reached, and was True.
3) The If was reached, and was False.
I put this php file into the right folder on the tablet, navigated to the file with my browser, which means a URL that looks like this, in this case:
http://192.168.1.110:8080/snorkel/index.php
and got back a response that showed option #3, so the file was working fine. I hadn't supplied an action, so option #2 was out of the question, which is fine. The point is that the file is working fine on the tablet and is accessible from the test computer.
Then, in the main program, which is a large JS/JQuery web app, I tested that the web application was able to reach outwards from the test environment by hitting a service on a different computer to update some tables. This worked as desired (well, actually one of the tables had an issue, but that's a different matter for me to investigate, but the other tables worked fine).
The final step was to test out the backup, which meant hitting that php page. I have tried various versions of this and have always gotten a really opaque result, which is why I'm asking here. The JQuery code for the call looks is this:
Code:
$.ajax({
type: "post",
url: tURL,
data: { action: 'test' },
success: function (data) {
if (data[0].ERROR !== "None") {
//Surplus stuff removed.
}
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
//Surplus stuff removed.
}
});
I then put a breakpoint inside the success and error methods. In all cases, I reach the error method. TextStatus shows 'error', and errorThrown is ''. I haven't been able to get any other result.
Originally, I tried this with a Get call rather than post, but there's never an answer. So, directly accessing the index.php file via a browser shows that it's there and responding as expected, but I have been unable to get anywhere with the JQuery approach.
Any help would be appreciated.