我想在点击按钮后运行函数。所有的都在一节课上。
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>