I'm encountering some issues when trying to call a PHP file using Ajax in my Mozilla Extension. Both the JavaScript (Ajax) and PHP files are located in the directory /myextension/content. Here is the function I use to make the Ajax call:
function ajaxFunction(){
var req = new XMLHttpRequest();
req.open('GET', 'myphp.php', true);
req.onreadystatechange = function (aEvt) {
if (req.readyState == 4) {
if(req.status == 200)
alert(req.responseText);
else
alert("Error\n");
}
};
req.send(null);
}
And this is how my PHP file looks like:
<? php
echo "Server Received with thanks!";
?>
However, when I try to run the code, I keep getting an "alert("Error\n");". Can anyone spot what I might be doing wrong?