I am trying to create a redirect page which sends data to the server before transitioning to a new page, with javascript like following code.
<body>
<script type="text/javascript">
****
light transaction about cookie
****
document.createElement("img").setAttribute("src", "server.php?param1=cookiedata");
location.href = "new_page.html";
</script>
</body>
However, before redirecting to "new_page.html", sometimes
document.createElement("img").setAttribute("src","server.php?param1=cookiedata");
is not called, and cannot send a data to "server.php".
Is it a problem that the redirect time is short?
Could you tell me how to solve?