I am new to php development and I am stuck on something stupid : I want to execute a php script from my html page.
I do the following to do so :
$.ajax({
type: "GET",
url: "test1.php",
success: function(response) {
//alert(response);
console.log(response);
},
error: function(response) {
}
});
But when I log the response, I see the php source code in the response :
[Log] <?php (localhost, line 23)
$output = "LALALALALALALALALALALALALA"
echo $output;
?>
Try this ... call in head tag
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
</head>
in javascript tag
$.ajax({
type: "GET",
url: "test1.php",
success: function (html) {
console.log(response);
},
error: function(response) {
}
});
return false;