Ajax call aborted auto

I have a very strange problem.

I have a regular ajax call that uploads an avatar that you select from your computer to the server.

it works sometimes, sometimes I see in Firebug under the network that after some loading time it gets "Aborted" and is marked in red.

I even have an ajaxend ajaxstart bootloader icon and the icon continues to show even when it is interrupted.

Why is this happening, and how can I prevent it from being interrupted? And maybe, how can I do a “try again” if it is interrupted? .. why is it even interrupted: S

Ive noticed that this happens in large demension / size files? And in the file that it requests (fileupload.php), I have a checker to cause an error if it is larger. But I think that it doesn’t even get into the file before it “falls behind” and stops.

Update confirmed: this happens when I try to send ajax file with a large size.

+3
source share
2 answers

How do you send files through Ajax? Ajax does not support sending files.

If this is a connection timeout in the jQuery console, it will be displayed in red and the ajax request error handler will be called.

, . timeout, timeout ajax. , - 30

$.ajax({
    url : "",
    data : {},
    success : function(data, textStatus, XMLHttpRequest){
    },
    error: function(XMLHttpRequest, textStatus, errorThrown){
        if(textStatus == "timeout"){
            alert("timeout")
        }
    },
    timeout : 600000
});

ajaxfileupload,

$.ajaxFileUpload({
    .....,
    timeout: 60000,
    error: function (data, status, e)
    {
        if(status == "timeout"){
            alert("timeout")
        }else{
            alert(status)
        }
    }
})

, .

+2

, , . jquery.

0

Source: https://habr.com/ru/post/1783315/


All Articles