I am attempting to accomplish the following:
function doThis()
{
firstFunction(function()
{
closeWindow();// close window only after firstFunction() completes
});
}
doThis() is invoked from a button. The firstFunction() is an AJAX call and upon its completion, a second non-AJAX function called alert() should be executed. However, it seems that the code is not working as expected. The firstFunction() is functioning properly and being invoked correctly. But the window.close action does not seem to be triggered.
Any suggestions? No jQuery solutions please.
update:
Let me provide more details on this. The doThis() function is called from a submit link.
<a href="#" name="sumbit" onClick='doThis()'><img src="img.png"/></a>
After clicking this link, the form should be submitted and the popup window closed. The firstFunction() uses XMLHttpRequest to POST the form and works fine when used like this:
<a href="#" name="sumbit" onClick='firstFunction()'><img src="img.png"/></a>
With doThis(), I am trying to submit the form first and then close the popup but haven't been successful.
update 2
As delnan pointed out, it appears that firstFunction was not executing the function passed to it as an argument. I made some changes and now it functions properly:
function firstFunction(callback)
{
//do ajax stuff
callback(); //calls closeWindow()
}
Thank you all!