开发者

Android jquery ajax error length required

I have a piece of code that works on most browsers except the Android browser. On Android if throws the following error: "Length Required"

Android OS: 2.2 jQuery: 1.5.1

$.ajax({
    type: "put",
    url: '/offers/' + offer.offer_data.id + '/delete_active',
    success: function(){
      alert('success');         
    },
    error:function(XMLHttpRequest,textStatus, errorThrown) {     
      alert("Error status :"+textStatus);  
      alert("Error type :"+errorThrown);  
      alert("Error message开发者_如何学编程 :"+XMLHttpRequest.responseXML);  
    }
});

Thanks in advance.


Adding a dummy parameter data fixed the issue. Found the answer in this post http://weblogs.asp.net/gabriellopez/archive/2010/03/12/jquery-web-service-invocation-411-length-required-error.aspx

$.ajax({
    type: "put",
    url: '/offers/' + offer.offer_data.id + '/delete_active',
    data: "{ blank:'blank' }",
    success: function(){
      alert('success');         
    },
    error:function(XMLHttpRequest,textStatus, errorThrown) {     
      alert("Error status :"+textStatus);  
      alert("Error type :"+errorThrown);  
      alert("Error message :"+XMLHttpRequest.responseXML);  
    }
});


try removing the data line as i see it is not needed in your request:

$.ajax({
    type: "put",
    url: '/offers/' + offer.offer_data.id + '/delete_active',
    success: function(){
      alert('success');         
    },
    error:function(XMLHttpRequest,textStatus, errorThrown) {     
      alert("Error status :"+textStatus);  
      alert("Error type :"+errorThrown);  
      alert("Error message :"+XMLHttpRequest.responseXML);  
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜