Problem:
On the site I'm building, I have two jQuery ajax long polls that are constantly waiting. Now I'm trying to set the file upload function so that when I click on the link, the user asks for the SaveAs window. This file upload is working fine, the problem is that when a link is clicked, two ajax calls are canceled.
I try either not to cancel the cancellation of ajax calls, or the ability to immediately configure ajax calls.
Here is the link code:
HTML:
<a href="/test" id="testfile">Tasks</a>
JS:
$(document).on('click',"#testfile",function(event){ event.preventDefault(); var href=$(this).attr('href'); window.location.href = href; updater(); notifier(); });
What I tried:
I have the code above, I tried to call two ajax calls after starting the download. This does not work. If I delay some delay so that calls are initiated after the download is complete, it works, but seeing that the files can be large and therefore take an unknown amount of time to receive, this is of course a bad decision.
I'm really confused, why are ajax calls canceled? Is this because the page is loading when I click the link?
Seeing that I am only working on a development server with a single thread, the new ajax calls that I try to configure right after the link may fail, because the server is busy, can this be so?
SOLVE:
I added a hidden iframe to the buttom of the site and targeted that with my link. I also deleted the JS code since ajax calls are no longer canceled.
Now the code is as follows:
HTML:
<a href="/test" target="filetargetframe" id="testfile">Tasks</a> ******** <iframe name="filetargetframe" style="display:none"></iframe>