Hey guys I have this page work.php with html and javascript codes and the form refers to index.php page. Also I am trying to pass the variable counter from my javascript to the index.php page. It's not working at all. Can you please have a look? I can't seem to figure out the issue.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<form method="post" action="index.php" enctype="multipart/form-data">
<div id=parent_div>
<button type="button" id="add_step" > Add step!</button>
<input type='submit' name='submit'>
<br/>
</form>
</div>
</body>
</html>
<script>
$(document).ready(function(e){
var counter=2;
function send_counter(counter) {
$.ajax({
url : "index.php",
type : "POST",
cache : false,
data : {
counter : counter
}
});
}
});
</script>
And here is my index.php page:
<?php
if (isset($_POST['submit'])){
$counter=$_POST['counter'];
echo "$counter";
}
?>