通过ajax显示bash结果

So i am new to php and ajax. I am trying to run a file in terminal and then return the result to the client side. Everyting is working fine but result is not displayed on client side. I echoed the result and i can see it. php is working fine but i think my ajax is wrong. SOme help please.

This is my php code

<?php
if (isset ($_POST["list"]))
{   
$listval1 = $_POST["list"]; 
$myfile = fopen("list.c", "w") or die("Unable to open file!");
fwrite($myfile, $listval1); 
fclose($myfile);
}

else
{
$output=shell_exec(' gcc /var/www/html/list.c');
//print_r($output);
echo "<pre>$output</pre>";
//echo"success";

}
?>  

This is my ajax code

jQuery("#list").click(function(){
console.log("button clicked");

jQuery.ajax({

url: "/simulation.php",

type: "POST",
data: {list:jQuery("#listarea").val()},
dataType: "html",


success: function() {
//console.log(data);
window.location = "/simulation.php" ;
} 
}, 


});


});