weixin_33694172 2015-12-24 00:10 采纳率: 0%
浏览 59

jQuery Ajax套接字错误

Happy holidays everyone. I'm getting occasionally the following ajax error:

Object error java.net.SocketException: Unexpected end of file from server

I have no space in data I send and encode the data as well. I have timeout set to 5000. I wonder if there is anything else I could try for the Socket error. Much appreciate your time... Here is my ajax call:

getURL = function(data){
    var obj = null;    
    obj = $.ajax({
         async:false,
         type:"POST",                 
         url: url,
         data: data,
         timeout: requestTimeout
      })             
    .done(function(data, textStatus, jqXHR){            
        if(data){
            if(data.status_code != 200)
            {
                console.log("ERROR Status returned:", data.status_txt);
            }
            else
            {                    
                url_rsp = data.data.url;
            }
        }
    })
    .fail(function(jqXHR, textStatus, errorThrown ){
        console.log("ERROR:", jqXHR, textStatus, errorThrown);
     });    

    return obj;   
}
  • 写回答

1条回答 默认 最新

  • 斗士狗 2015-12-29 00:20
    关注

    I was able to get around the error by forcing a second ajax post attempt after fail and that appears to cover most failed cases... The server is a 3rd party server, so I have no details on why the first post could fail.

    评论

报告相同问题?