I have this simpel ajax call to a php page.
$(document).ready(function(){
$('#imgUpload').on('change', function () {
$.ajax({
url: './php/dataUpload.php',
type: 'POST',
data: {boxId: boxId },
dataType: "html",
success: function(data){
var box = $(data);
alert('Do it!');
},
});
});
});
On change the js-code will executed and I get a response from the php code. I don't know why however the result is the whole php code and not only the echo's..
The php code is:
<?php
if(isset($_POST['boxId'])){
echo $_POST['boxId'];
} else {
echo "blub";
}
?>
It's on a local server. Calling the php code only will echo "blub" to the browser-window so the php-code works.
Here the result of the ajax call if changed it to <?php echo "blub"; ?>
:
"<?php↵ echo "blub";↵?>"