I have a method which calls a another method which inturns has some ajax call to the back end.
MethodB(){
MethodA()// this has some ajax functionality
setpopupposition()// wants to overwrite x,y postions after MethodA sets...X,y postion.
}
MetodhA(){
AjaxCall();
Setx Popup to x,y location
}
The problem here is MethodA sets the popup postion to a x,y location ,but i want to overwrite x,y location to a different postion after the call to MethodA.The issue i am facing here is my setpoupuppostion in MethodB is getting executed before MethodA.
I want to execute setupuppostion() inside MEthodB only after methodA completes, can you please advice me how to do that.
MethodA is completing, though. All you have in Method A is the AJAX call and the popup position setting function. These will both get called and then Method B will move on. (Note Method A is not waiting for the AJAX call to complete. It’s just initiating it.)
An alternative would be to have a callback generated by the AJAX call, true on success/false on failure, and then pass that on from Method A to Method B. In Method B you could implicitly wait for that return before continuing, or only continue if it’s true.
If you need help making your AJAX call return true/false, update the question with your existing AJAX method and I’ll update it for you.