Javascript: open popup, wait till loaded, close

Vadim Rapp
Vadim Rapp used Ask the Experts™
on
In SSRS report showing pending invoices, in the last column I have a hyperlink that marks the invoice as sent. This is accomplished by setting Action to the following:

="javascript:w=window.open('http://myserver/MarkInvoiceAsSent/?invoice_id=12345');w.close();document.location.reload(true);"

"MarkInvoiceAsSent" is an asp page that quietly performs the requested database transaction, with no output. "12345" is for this example only, in fact it substitutes the correct value from this row.

The problem is that w.close closes the page before it has opened, so the transaction is not performed.

Is there a way to modify javascript so that it would wait until the page is complete before closing it? Or perhaps some other way to accomplish this.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Found the way;

="javascript:var xmlhttp = new XMLHttpRequest();xmlhttp.open('GET','http://myserver/MarkInvoiceAsSent/?invoice_id=12345');xmlhttp.send();document.location.reload(true)"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial