K
K
Konstantin2017-10-06 14:08:07
JavaScript
Konstantin, 2017-10-06 14:08:07

How to download a file asynchronously?

Am I doing it right?
The form

<asp:FileUpload ID="fileUploader" runat="server" ClientIDMode="static" AllowMultiple="true" onchange="$('#loadGeom').click();" />
                                <asp:Button runat="server" ID="loadGeom" Text="Загрузить файл" ClientIDMode="static"  OnClick="loadGeom_OnClick" Style = " display : none" UseSubmitBehavior="False"/>
                                <asp:Label ID="Label1" runat="server"></asp:Label>


js code
$("#fileUploader").click(function () {
            if (this.value != '') {
                document.getElementById("<%=loadGeom.ClientID %>").click();

                $.ajax({
                    url: "~/forms/LandLayout/LandLayoutE.aspx",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    async: true,
                    dataType: "json"
                });
            }
            
        });


and in the method itself the file is loaded.
Everything works, the question is: is it asynchronous loading or not? I've never dealt with this before, so I'm asking for advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2017-10-06
@Klass

This is an asynchronous download. Ajax makes requests asynchronous by default, unless you set async: false yourself. Checking asynchrony is easy, the page should not block during the request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question