I have below code. I don't know much about ajax. I want below input s_amount to convert as a php variable before submitting the form that it is in. There are some syntax errors where param1 in php code is not recognised. I don't know my order is correct or not. How I get this work.
<input type="text" name="s_amount" >
<script>
$.ajax({
url: 'payment.php',
type: 'POST',
dataType: 'text',
data: {param1:$("input[type='text'[name='s_amount']").val()},
})
.done(function(response) {
console.log("response");
responsen=response+1;
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
$param1=done(param1);
</script>
<?php
$myphpvariable= $_POST['param1'];
echo 'this is my php variable: '.$myphpvariable;
?>