I use the following code to select data to show the user without having to move to another page.
<script type="text/javascript">
$(document).ready(function() {
$('#testform input[name=date]').datepicker({
autoHide: true
});
$('#testform').submit(send);
});
function send() {
const data = $(this).serialize();
$('#output').text("FormData: " + data);
$.ajax({
type: "POST",
url: "receiving_file.php",
data,
success: function(data) {
document.getElementById("PrintData").outerHTML = data;
document.getElementById("PrintImg").src = data;
}
});
return false;
}
</script>
To display the output without going to another page, I write in the code:
<p id="PrintData">
The code in the file receiving_file.php looks like this:
<?php
$date = $_POST['date'];
print $date;
?>
The problem is that I want to use JavaScript within the data that comes and it does not work. However, when I try to view the source code in the browser I can't see the data.
Does anyone have an idea how to solve the problem?
Thanks