I tried to create a simple AJAX call to php script.
request.js
var xhr = new XMLHttpRequest();
xhr.open('GET', './assets/script/api/sample.php');
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) {
console.log(xhr.responseText);
}
}
xhr.send();
sample.php
<?php echo "Hello World"; ?>
Error:
Failed to load resource: the server responded with a status of 404 (Not Found) (localhost:7456/assets/script/api/sample.php)
/assets/script/api/sample.php
the correct path to sample.php? – Bravohttp://localhost:7456/assets/script/api/sample.php
in your browser address – Bravo