troubleshooting Question

setTimeout() sending a page twice

Avatar of softechnics
softechnics asked on
3 Comments1 Solution806 ViewsLast Modified:
I have a web app running JSP pages under Struts/Websphere. I am trying to implement test code so I can do load/performance testing as follows:

1. Start a browser and log into the application
2. Press 'F2' on the page and it sets a flag putting the client in loop mode.
3. Press the form's submit button
4. The next lookup page checks the loop flag and, as a result of it being set, calls the sendLoopTestPage() function, which automatically submits the form with a new item (selected randomly from an item code array).

I have the following Javascript function:

function sendLoopTestPage() {
form.ITEMCODE.value = itemCodeArray[Math.floor(Math.random() * itemCodeArray.length)];
setTimeout ("form.submit()", 2000);

Problem: This function causes the page to be submitted twice. If I replace the setTimeout() function call with a dummy function that does nothing, the page is not sent at all, unless I press the form's submit button.

Any ideas why the form is being submitted twice?


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros