I want after click button run function, . All is in one class.
JQUERY
jQuery('#text2').click(function() {
var data = {
'action': 'myfunction',
'whatever': $button.data('text2'),
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
alert('Got this from the server: ' + response);
});
});
PHP
public function myfunction() {
$write = intval( $_POST['whatever'] );
$write++;
echo $write;
wp_die();
}
HTML
<button id="text2" value="1500"> test </button>