There is a certain function (the 20th on the list in the call stack). It causes a modal window.
When corresponding GUI to the Web UI, the question arose of implementation modality via AJAX.
To give the window the browser, you need to terminate a thread, in which you launch the modal window.
To complete the flow, you need to get the results of the dialog box. That's the essence of the problem.
Two failed solutions:
1. Cut all 20 functions into 2 parts. All of that to the modal window, the window itself is given and is fulfilled in the first thread.
All that after in the second. Cut function 2 is necessary in order to be able to share "before" and "after".
2. To stop the flow, which reached a modal window. Create a second thread that gives the browser the modal window. On return from the modal window, restore the first thread.
The first option will break the object-oriented, labor-intensive. The second option is difficult to implement, requires a low level of operation and intervention in already existing modules.
Is there any option pharmaline?