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;
}
);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.