Onclick javascript function need to perform two actions.
- download a file with window.location.href = url
document.getElementById('test').submit();
I am not able to implement both. If the submit function is added, download is not working. Any thoughts on how to achieve both. Thanks.
Looks like you can’t do that because when submit happens, previous request for that page is closed. People suggest an iframe for file download, but submit will unload old page with iframe in it, so I do not think it will work. Suppose instead of that you should use
window.open(url)instead ofwindow.location.href = urlThis way you will open completely new window which will download a file and submit will happen in old one.