Support

Account

Home Forums ACF PRO Loading New Advanced Custom Fields Row With Ajax Reply To: Loading New Advanced Custom Fields Row With Ajax

  • So, if you want to only return one value, you don’t need to really use json, but it’s still a good idea. The problem with your code is that you’re not adding to the current row, you’re just returning the same value you’re sending.

    
    add_action( 'wp_ajax_my_ajax_action', 'my_ajax_action_callback' );
    add_action( 'wp_ajax_nopriv_my_ajax_action', 'my_ajax_action_callback' );
    function my_ajax_action_callback() {
        if(isset($_POST['newRowId'])){
        
            $new_row_id = $_POST['newRowId']+1;
            echo $new_row_id;
            exit;
        }
        else {
            echo "its null mannn";
            exit;
        }
    }