Tag Info

Hot answers tagged

3

To pass data from js back to PHP simplest way is use json_encode or, in WP, its wrappers wp_send_json, wp_send_json_error and wp_send_json_success. Usage example: On PHP side function get_latest_product_meta() { $post_id = (int) filter_input(INPUT_GET, 'post_id', FILTER_SANITIZE_NUMBER_INT); $post_id or wp_send_json_error(); // array_shift ...


2

using wp_die(); at the end of AJAX function fixed the issue for me. e.g add_action( 'wp_ajax_my_ajax_function', 'my_ajax_function' ); function my_ajax_function(){ echo json_encode($myvar); wp_die(); }


2

Perhaps this solution will work: var flag_ok = false; $('#publish').on('click', function (e) { if ( ! flag_ok ) { e.preventDefault(); var url = shiftajax.ajaxurl; var shift = $('#post_ID').val(); var data = { 'action': 'wpaesm_check_for_schedule_conflicts_before_publish', 'shift': shift, ...


1

Placing this answer for those people who're trying to fix the same issue. It's important where add_action('wp_ajax_setAsyncCheckProduct', [$this, 'setAsyncCheckProduct']); resides. In my case the issue was finally fixed moving a similar line to the main plugin file, where all concrete classes are included and initialised. Of course the line had to be ...



Only top voted, non community-wiki answers of a minimum length are eligible