ajax call aborted auto
Im having a very weird issue.
I have a normal ajax call that upload the avatar you choose from your pc up to the server..
this works sometimes, sometimes i can see in firebug under the Net that after some time loading, it gets "Aborted" and marked in red.
i even have a ajaxstart ajaxend loader icon and the icon keeps showing even when it gets aborted.
Why is this happening, and how can i prevent it from a开发者_如何学运维borting? And maybe how can i make a "try again" if it got aborted?..why is it even aborted :S
Ive noticed it happening on bigger demension/size files? And on the file it request(fileupload.php) i do have a checker there, to callback an error if its bigger. But i think it does not even get to the file before it "lags" and stops..
Update confirmed: this occurs when i try to ajax send file with bigger size..
How are you sending files through Ajax? Ajax does not support sending files.
If it is a connection timeout in jQuery console it will show in red color and the failure handler of the ajax request will be called.
You can handle any conditions you want there. To remove timeout
issue you can add a attribute timeout
to your ajax request. I think the default value is 30 seconds
$.ajax({
url : "",
data : {},
success : function(data, textStatus, XMLHttpRequest){
},
error: function(XMLHttpRequest, textStatus, errorThrown){
if(textStatus == "timeout"){
alert("timeout")
}
},
timeout : 600000
});
Since you are using ajaxfileupload try this
$.ajaxFileUpload({
.....,
timeout: 60000,
error: function (data, status, e)
{
if(status == "timeout"){
alert("timeout")
}else{
alert(status)
}
}
})
And make sure that you does not have any max file upload size set in your server.
It probably got aborted because the request timed out on the client side. Increase the timeout in jquery.
精彩评论