?
Solved

Javascript how to be sure function executed successfully

Posted on 2009-02-18
3
Medium Priority
?
264 Views
Last Modified: 2013-11-19
My operation takes long time to finish.

<html>
<head>

function doOperation(){

     //do somethin if something executed successfully then close window. but be sure .


}
</head>
<body>
<a href="#" onclick="doOperation();">Do Operation Then Close Window</a>
</body>
</html>

How can i be sure is my operation finished.

Thanks. Please Help.
0
Comment
Question by:phparmy
3 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 23670882
It depends upon the operation.  There are so many possibilities.

What kind of operation is it?
0
 
LVL 8

Accepted Solution

by:
Barry62 earned 1000 total points
ID: 23671071
Javascript is a top-down language.  Meaning, it executes one statement at a time from the top down.  

You could put the window close statement in a second function.  Then at the end of the doOperation function make an if statement testing for a condition that you set if your operation completes.  If it is true, call the close function.  If the operation does not complete, don't set the condition to true, and the close function is not called.
0
 
LVL 17

Expert Comment

by:nplib
ID: 23672080
Can you give an example of something you want to do?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question