I have the following javascript function:
function test() {
jQuery.post("http://www.example.com/test.php", {})
.done(function(data) {
alert(data);
})
.fail( function(xhr, textStatus, errorThrown) {
console.log(xhr);
console.log(textStatus);
console.log(errorThrown);
});
}
And the test.php file reads like this:
<? echo "TEST"; ?>
When I call this function either by clicking on something on my page, either by typing it to the console, the alert is not firing, instead the fail part of the jQuery.post is being fired, where I get the following values:
xhr -> object
textStatus -> "error"
errorThrown -> ""
I've checked firefox debugers network, where I see that the request is being sent to the desired url, and the little circle at the left side gets green, which means that I get some kind of response from the server, but the transfered column is a single "-" line, and the received column is 0 bytes. If I call the page "http://www.example.com/test.php" from a browser, it works correctly.
What could be the problem, or how could I proceed on debuging this error?
Figured out the problem, see my own answer below, if anyone experiences the same error:|