It seems that since i have a "for loop" and multiple if/else scenarios, the callback never gets fired. When I remove the "for loop" it works fine. What am I doing wrong here? How do I force the callback to wait until all the for loops and conditionals are complete? Thanks!
var myArray = ["one","two","three","four","five","six","seven","eight","nine","ten"];
function myFunction(arg1,arg2,arg3,arg4,arg5,callbackFunction){
if (arg1 == "arg1"){
for (var i=0; i<=myArray.length; i++){
if(arg2 == "arg2"){
if(arg3 == "arg3"){
if(arg4 == "arg4"){
//some code
}else{
if(arg5 == "arg5"){
//some code
}else{
//some code
}
//some code
}
}else{
//some code
}
}
else{
//some code
}
}
}else{
//some code
}
if (callbackFunction){
callbackFunction();
}
}
myFunction("arg1","arg2","arg3","arg4","arg5",function(){
alert("done");
});