I am trying to send variables using ajax to php page so when I click a button, the sent variable will update to the page without refreshing it.
I have a button called #toshow and when clicked, it will send ?show=okay as a post.
$('#toshow' ).click( function( e ) {
$.post('?show=okay')
.done(function(data) {
});
});
and on my php
if(isset($_POST['show']) && $_POST['show']) {
echo $_POST['show'];
}
I click the button, but it doesn't show the text 'okay'. What else do I need to add to make this work?
Thank you!
.done()callback to take the data and place it wherever it's needed.