I wanna pass a JavaScript variable in to PHP, that's my code:
$('.info-button').on('click', function() {
var flag = $(this).data('flag');
if (flag) {
var index3 = $(this).parent().parent().parent().find('img').attr('src');
console.log(index3);
$('.inner').css("display", "block");
} else {
$('.inner').css("display", "none");
}
$(this).data('flag', !flag);
});
How to get index3, which is dynamic variable from PHP?
I tried with:
<?php
echo "<script>document.writeln(index3);</script>";
?>
But Im getting index3 is not defined