2011-04-27 22 views
1

我有一段代碼可以在除Android瀏覽器以外的大多數瀏覽器上使用。在Android上,如果引發以下錯誤: 「必要的長度」Android jquery ajax所需的錯誤長度

Android操作系統: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); 
    } 
}); 

在此先感謝。

回答

1

添加一個虛擬參數數據固定的問題。在這篇文章中找到答案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); 
    } 
}); 
0

嘗試刪除data行,因爲我看到它是不是需要在您的要求:

$.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

我剛剛試過。沒有運氣。我將從代碼中刪除該部分。 – Nicolo77 2011-04-27 18:58:23