I am sending a javascript value in a hidden form to a php script. This is the code.
<script type="text/javascript">
$(document).ready(function() {
$('form').submit(function(e) {
var mydata = 3;
if ($(this).is(':not([data-submit="true"])'))
{
$('form').append('<input type="hidden" name="foo" value=mydata>');
$('form').data('submit', 'true').submit();
e.preventDefault();
return false;
}
})
})
In my php script, I am accessing the value like below.
$src1= $_POST['foo'];
echo $src1;
I have initialized mydata to 3. I am expecting the output to be 3 in my php script, but instead I am getting the string mydata.
<form>on your page.