Server_side wait for result | WordPress.org

Hello!

What is the proper way to have desired behavior:

let r = SERVER_SIDE(‘myFunction’, myParams);
wait till r gets response
only after that run other code

I have one calculated field with many functions in it, and I call the server 2-4 times. The first 3 calls the behavior is: JS runs the next code without waiting for response from server, then gets response and reruns the code with this response.
So I was able to have a check

if (typeof serverResult !== ‘undefined’ && serverResult !== null && serverResult.length > 0) {
code after receiving response
}

And everything worked. But yesterday I added a fourth call to the server and function finishes before receiving any response.

I see in Console that request was sent correctly and response was received, but I can’t force JS to wait for it.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer