<input type="button" class="btn" value="Place Order" onclick="myFunction()">
<script type="text/javascript">
const sessionData = '<% String resp= session.getAttribute("jsonData").toString(); %>';
const jsonData = JSON.parse(sessionData);
function myFunction(){
alert(JSON.stringify(jsonData));
}
</script>
I am attempting to retrieve a JSP variable and store it in JavaScript, then display it in an alert. However, when I try this, I receive an error saying "function myFunction is not defined".