I’m trying to use jQuery to post a variable to a MySQL/PHP query. I have a button, class="button" and the button code is:
$(".button").click(function(e){
e.preventDefault();
$.post("some.php", { var_today : <?php echo $new_var; ?> });
});
using:
if(isset($_POST['var_today'])){
echo $_POST['var_today'];
}
on my php page, and I get undefined index: var_today
the class button tag has an onclick="window.open('') attached to it, and once it’s clicked, I get “undefined index” as the var_today is not being posted, what have I written wrong here?
This should work.