Support

Account

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.