Tell us what you are trying to do?
How to make value of "add people" automatically updated without refreshing the page after I submit new data with "add new person" form.
Could you give some more details about how you have this set up, so we can understand the problem?
Am I right in thinking you have a form (to submit posts), and that form includes an "Add People" dropdown for a field which stores "people" (user ids?). You also have below that an "Add new person" button.
Does that open a new form to add a person, and you expect that person to then be available in the Add people dropdown selector?
I'm struggling to see how this might work, because HTML does not permit nesting forms, maybe this second form is added later to the page and you use a modal to display it.
In which case you may be able to use JavaScript to add an option to the Add people select dropdown, but it rather depends on the setup.
Could you please give more details about how you are implementing this?
Am I right in thinking you have a form (to submit posts), and that form includes an "Add People" dropdown for a field which stores "people" (user ids?). You also have below that an "Add new person" button.
Yes, dropdown data is populated from another post type (People post type). "Add new person" will show pop up "add new person form" to add new person use AJAX. I am expecting the new submitted data will be available on Add people dropdown selector without refreshing the page. Is that doable with Javascript?
There is no built-in hook or filter, that can be used to selectively update a selective field through AJAX. Based on this you have two options:
1. You can set the whole page to refresh when the 'add new person' form's submission is completed.
OR
2. You'll need a completely custom script that fires when the pop-up for the 'add new person' form is closed and through a custom, AJAX call gets the latest people post's list and shows them as options in the "Add people" list.
Here are some useful guides on implementing custom AJAX calls in WordPress: hidden link hidden link
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors: https://toolset.com/contractors/