Skip to main content

Bug Tracker

Side navigation

#13965 closed bug (cantfix)

Opened May 29, 2013 09:41PM UTC

Closed March 04, 2014 05:12PM UTC

ajax request never completes if user downloads a file

Reported by: gustavo_armenta@yahoo.com Owned by: jaubourg
Priority: low Milestone: None
Component: ajax Version: 2.0.0
Keywords: Cc:
Blocked by: Blocking:
Description

When doing an ajax request that takes a long time to complete, if the user clicks a link to download a file and stays on the same webpage, the ajax request never raises an event like done, error, complete, etc

To repro this bug, I need a long standing request on server side and I don't know how to repro on JSFiddle but here is a Visual Studio solution, just download ajaxSend.zip

https://skydrive.live.com/?cid=8dce4b0da74046fc&id=8DCE4B0DA74046FC%21653&authkey=!AOoPQze7o_V-D4w

Attachments (0)
Change History (12)

Changed May 30, 2013 01:06AM UTC by dmethvin comment:1

owner: → gustavo_armenta@yahoo.com
status: newpending

That's way too much code. Can you provide a simple test case that doesn't require external libraries? Even if it's just a standalone file. Otherwise, it's likely that the problem is caused by one of the other things in the file. See also #13883 which seems to be reporting the same problem, but also was too large/unclear.

Changed May 31, 2013 08:16PM UTC by gustavo_armenta@yahoo.com comment:2

status: pendingnew

I have hosted the application on this URL: http://signalr01.cloudapp.net:82/

Now, your repro code is minimal, only the HTML and JS available on the browser :)

Changed June 01, 2013 05:34PM UTC by m_gol comment:3

status: newpending

I'm sorry but I can't reproduce it. Here's a test case on jsFiddle:

http://jsfiddle.net/5YGVB/1/

http://jsfiddle.net/5YGVB/1/show/light/ (a standalone test without iframes)

I used a web page http://mgol.eu/sandboxes/longwait/ I've just created. Its whole code is:

<?php
	sleep(6);
	header('Access-Control-Allow-Origin: *');  
	header('Content-Type: application/json');
	echo '{"a":2}';
?>

You can use this page for your tests if you want but we do need a test case on jsFiddle to be able to investigate. If your problem require a different response, I can update the PHP test but you can also do it on your own server; just remember to set the Access-Control-Allow-Origin header to * or jsFiddle won't be able to start an AJAX request against this page.

Changed June 03, 2013 08:34PM UTC by gustavo_armenta@yahoo.com comment:4

status: pendingnew

Use a word document as the file to download.

I can repro the issue when the link is created as "<a href". The issue goes away when the link is created as "<a download href".

"download" keyword is HTML5 so it works only on latest browsers.

Changed June 03, 2013 08:37PM UTC by dmethvin comment:5

So does this problem happen with all browsers? What OS are you using?

Changed June 03, 2013 09:20PM UTC by m_gol comment:6

_comment0: OK, I can reproduce it, situation is as follows (I changed the test case to not use the download attribute): \ 1) Chrome & Safari fail the test \ 2) on Firefox`always` & `fail` fire. \ 3) on IE10`always` & `done` fire. \ I'm unable to test IE9 in this way because it doesn't support CORS. \ \ http://jsfiddle.net/5YGVB/2/show/light/1370294508148058
_comment1: OK, I can reproduce it, situation is as follows (I changed the test case to not use the download attribute): [[BR]] \ 1) Chrome & Safari fail the test [[BR]] \ 2) on Firefox`always` & `fail` fire. [[BR]] \ 3) on IE10`always` & `done` fire. [[BR]] \ I'm unable to test IE9 in this way because it doesn't support CORS. \ \ http://jsfiddle.net/5YGVB/2/show/light/1370294759008356

OK, I can reproduce it, situation is as follows (I changed the test case to not use the download attribute):

1) Chrome & Safari fail the test

2) on Firefox always & fail fire.

3) on IE10 always & done fire.

I'm unable to test IE9 in this way because it doesn't support CORS.

http://jsfiddle.net/5YGVB/2/show/light/

Thanks for your report, gustavo!

Changed June 03, 2013 09:24PM UTC by m_gol comment:7

#13883 is a duplicate of this ticket.

Changed June 04, 2013 02:03PM UTC by timmywil comment:8

component: unfiledajax
owner: gustavo_armenta@yahoo.comm_gol
priority: undecidedlow
status: newassigned

Changed November 10, 2013 09:53PM UTC by m_gol comment:9

owner: m_goljaubourg

jaubourg claims it's not possible to fix this one without re-introducing all the logic from 1.x.

Reassigning to jaubourg so that he can close the bug as wontfix if he wishes.

Changed March 04, 2014 04:49PM UTC by dmethvin comment:10

@jaubourg, can you provide some more background about why this happens? I assume it has something to do with our switch from onreadystatechange?

Changed March 04, 2014 05:08PM UTC by jaubourg comment:11

It's a browser issue. Clicking on a link will abort outbound requests. The fact this is a download link is irrelevant. On mobile Safari, for instance, downloads will be on a new page. Fact is, browsers will abort early, before they know if an actual in-place navigation will occur.

Of course, this behavior is not 2.x specific.

Changed March 04, 2014 05:12PM UTC by dmethvin comment:12

resolution: → cantfix
status: assignedclosed

Oh that makes sense, and it's something we can't control.