Home › Forums › ACF PRO › How to reload an ACF meta box with jQuery / AJAX › Reply To: How to reload an ACF meta box with jQuery / AJAX
So the problem is that you’re not returning anything in from the ajax request.
In you function ajax_acf_load_models_field_choices()
you’re looking at the global $post value, but during ajax $post will not contain anything.
If you want to have the post ID of the current post then you need to put that into a localization value for your script and then send that as part of the request.
You can see how the localization is done on line 114 of this file https://github.com/Hube2/acf-dynamic-ajax-select-example/blob/master/dynamic-fields-on-relationship/dynamic-fields-on-relationship.php and how it is passed back in the ajax request on line 77 of this file https://github.com/Hube2/acf-dynamic-ajax-select-example/blob/master/dynamic-fields-on-relationship/dynamic-fields-on-relationship.js.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.