Support

Account

Home Forums Backend Issues (wp-admin) How can I send an additional field during ajax requests? Reply To: How can I send an additional field during ajax requests?

  • Not sure this will help but, this appears to be working. I don’t know that much about how this works to be honest, I used your JS and added it using the instructions here http://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/

    Only to discover that the script was not actually included anywhere in the page.
    Tried quite a few variations and found that setting a priority of 1 got it to load. And I can’t tell you why the script is not loaded without setting the priority.

    PHP

    
    function my_admin_enqueue_scripts() {
        wp_enqueue_script(
            'my_admin_script',
            get_template_directory_uri().'/js/test.js',
            array(),
            '1.1.0',
            true
        );
    }
    add_action('admin_enqueue_scripts', 'my_admin_enqueue_scripts', 1);
    

    JS File:

    
    acf.add_filter(
    	'prepare_for_ajax',
    	function(a,b,c) {
    		// This never gets triggered! :(
    		console.log('Filter args:', a,b,c);
    		return a;
    	}
    );