Example I have this line of code in PHP, and I want to pass these values when button is click and receive it by the jquery. How should I do this? I have started this codes and I don’t know what is the next step on it.
PHP Code:
<?php
echo '<button>Get the values</button>';
$name = 'sample name';
$age = 'sample age';
$add = 'sample add';
?>
JQuery Code:
$(function() {
$('button').live('click', function() {
$.ajax({
url: 'recieve.php',
type: 'post',
data: { get_name: pass_name, get_age: pass_age, get_add: pass_add },
success:function(){
}
});
});
});
Could you not just get php to echo out the variables in the JS. Like this: