EDIT: Cavid Kərimov's answer does work. Setting the form as below does also work.
<form onsubmit="return false;"></form>
I'm trying to retrieve a simple string of text from a PHP file using jQuery and AJAX as shown below:
index.html
$.get("echo.php", function(data, status) {
console.log("success: " + data);
}).fail(function(jqXHR, textStatus, error) {
console.log("failed: " + JSON.stringify(jqXHR));
});
echo.php
<?php
echo "echoed from php successfully";
?>
But I'm getting the following error:
failed: {"readyState":0,"status":0,"statusText":"error"}
I googled around for a bit and apparently this happens because of the Same-origin Policy, however I'm sure that isn't the case here because the HTML and PHP file are stored in the exact same folder on the server.