I am very new to JavaScript and need to use callback function in my java script function. I don't know how to use a callback function. Below is my code:
function SelectedFeature() {
// Here is my code call_Method1();
call_Method2();
}
The problem in the above function is that, call_method2()
starts executing before call_Method1()
ends its execution. To solve this problem, someone told me to use a callback function. Now how can I use callback function in my SelectedFeature()
function? Please explain by using code sample.
I'm making an asynchronous request in call_method1()
. I need call_Method2()
should be called after completing execution call_method1()
. But in my case, call_method2()
calls before call_method1()
completes its execution. Now how can I fix this?