How to send and recieve info from php file with XMLHttpRequest?
I try using XMLHttpRequest and jquery ajax. In both cases work find, but I can't extract the data.
Js file
var parametros = {
"url" : url
};
var xhr = new XMLHttpRequest();
xhr.open("POST", "file.php", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
alert(xhr.responseText)
}
}
xhr.send(parametros);
file.php
<?php
$str = $POST['url'];
echo $str;
?>
The alert show me all the php file, with php tags (plain text). How to recieve only the $str var?
EDIT: manifest file:
{
"name": "Get pages source",
"version": "1.0",
"manifest_version": 2,
"description": "Get pages source from a popup",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["http://localhost/extencio/*"]
}