Waiting for Form Submit Postgresql table message record insert before displaying message list

I have a form input submit that inserts a message in a Postgresql table, I need to synchronize the insert so that after the insert I can display the newly inserted message. My problem now is that I am using Form Dynamic Event Success and Action to try to display or reload the display listing of messages. The last message inserted is in the database but never gets displayed. Any ideas or suggestion? It displays all messages before the last inserted message.
See below code:

<div class="message-text-container">

                        <form method="post" is="dmx-serverconnect-form" id="formSendMessage" action="../dmxConnect/api//user_send_message.php"

                         dmx-on:success="run([{run:{action:`scDialogs.load({friendid: varReceiverID.value},true)`,name:'loadDialogs'}},{run:{action:`formSendMessage.reset()`,name:'resetMessages'}}])" ondone="reloadMessages();setScrollPosition();"

                            dmx-on:unauthorized="scLogOutMessages.load()" onstart="setScrollPosition();">

                            <input type="hidden" name="reciverid" id="idreceiverid" dmx-bind:value="varReceiverID.value">

                            <textarea class="pr-3" name="message" id="idmessage" required="" maxlength="500" dmx-bind:disabled="state.executing || scReceiverInfo.data.query.status != 1"></textarea>

                            <button title="send" type="submit" dmx-bind:disabled="scReceiverInfo.data.query.status != 1">

                                <span dmx-show="!state.executing"><i class="fa fa-paper-plane"></i></span>

                                <span dmx-show="state.executing"><i class="fa fa-spinner fa-spin"></i></span>

                            </button>

                        </form>

                    </div>
Community Page
Last updated: