in file anywhere in script tag
var data = {
'action': 'staple_dist',
'wpcf-preis-km-8-meter-bus': values
};
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
$.post(ajaxurl, data, function(response) {
alert(response);
if(response === 'success'){
alert('Message Sent Successfully!');
}
});
in functions , just replace highlited words
add_action('wp_ajax_staple_dist', array('CVF_staple_dist', 'staple_dist') );
add_action('wp_ajax_nopriv_staple_dist', array('CVF_staple_dist', 'staple_dist') );
class CVF_staple_dist {
public static function staple_dist() {
print_r($_POST);
/* foreach ( $_POST as $key => $value ){
update_user_meta( get_current_user_id(), $key, $value );
}
exit(); */
}
}
var data = {
'action': 'staple_dist',
'wpcf-preis-km-8-meter-bus': values
};
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
$.post(ajaxurl, data, function(response) {
alert(response);
if(response === 'success'){
alert('Message Sent Successfully!');
}
});
in functions , just replace highlited words
add_action('wp_ajax_staple_dist', array('CVF_staple_dist', 'staple_dist') );
add_action('wp_ajax_nopriv_staple_dist', array('CVF_staple_dist', 'staple_dist') );
class CVF_staple_dist {
public static function staple_dist() {
print_r($_POST);
/* foreach ( $_POST as $key => $value ){
update_user_meta( get_current_user_id(), $key, $value );
}
exit(); */
}
}
Comments
Post a Comment