I am trying to call a php function within a javascript function. I have attempted this via the code blow:
<?php
function insertData(){
//codes to insert into database
}
?>
and a javascript like this
<script>
function goBack(){
if (varx==confirm("Do you want to refresh page)){
//do something
}else{
document.write("<?php insertData() ?>");//calls the function
}
</script>
don't mind the punctuation, I just want to know if it's possible to achieve this ?