Admin ajax add tag callback

Is it possible to add an additional callback to admin ajax? Basically, I’m trying to increment the value in an input field of the add form for a custom term after the form is submitted. After the form is submitted via ajax, the response that comes back appends the new row at the top of the table of terms on the right side of the add form. I want to be able to update a field in the add form itself.

Something like the following is what I need executed after the ajax call is made:

Read More
function add_tag_increment_num() {

    echo '<script>
            var num = $("#num-field").val(); 
            var incrementedNum = parseInt(num) + 1; 
            $("#num-field").val(incrementedNum);
         </script>';

    die(); 
}

add_action( 'admin_ajax_add_tag', 'add_tag_increment_num' );

Any help would be greatly appreciated.

Related posts

Leave a Reply