I am making the following jquery ajax call to a codeigniter php function:
$.ajax({
type:"POST",
url: "Ajax/getHtml",
data: { u : 'http://stackoverflow.com/' },
contentType: "application/json; charset=utf-8",
dataType: 'html',
success: function(data) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('error');
console.log(jqXHR,textStatus, errorThrown);
}
});
The requested php function is :
public function getHtml() {
var_dump($_POST);
$url = $_POST['u'];
$result = file_get_contents($url);
echo ($result);
}
var_dump($_POST) yields:
array(0) { }
How can I fix this?