EDIT: Duplicate
Phonegap Cordova Ajax requests 404 (Not Found) Error
I am creating an android phonegap application and I have come across a problem which has never caused any problems in the past. The only thing I can think of is that I changed hosting recently.
The code below returns a 404 status when trying to POST data to a PHP file.
Sample data variable:
{q: 8, Email: "example@gmail.com", Pin: "0000"}
Ajax Call
function CallAjax(data, successFn, errorFn) {
$.ajax({
url: "http://www.gigtimes.co.uk/app/test.php",
data: {postdata: data},
async: true,
type: 'POST',
dataType: 'json',
success: successFn,
error: errorFn
});
return false;
}
When I access http://www.gigtimes.co.uk/app/test.php through the browser it works perfectly fine, but when accessing it through the app it returns a 404.
test.php
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type");
echo "{\"message\": \"hello\"}";
?>
Any help is appreciated. Thanks