2011-06-03 33 views
2

我想知道如何得到執行取()操作後返回的HTTP狀態代碼。我已經爲fetch()調用指定了onComplete和onError回調函數。 使用onerror被稱爲在錯誤的情況下,但我無法獲得從傳遞給onerror的參數的HTTP狀態代碼(這只是請求,而不是響應)。道場JsonRestStore,取,onerror的回調和HTTP狀態代碼?

隨着XhrGet我能夠從ioArgs獲得狀態代碼,似乎JsonRestStore不處理它的方式。

我使用道場1.5.1(我真的還不能升級到1.6)

回答

0

錯誤處理給出兩個參數。第二個參數(我稱之爲config)有一個名爲xhr的屬性,其中包含狀態和狀態文本。

dojo.xhrGet({ 
    url:'/bogusPath/', 
    error:function(error, config){ 
     console.log('XHR-ErrorHandle',arguments); 
     console.log('XHR-ErrorHandle-status:',config.xhr.status); 
     console.log('XHR-ErrorHandle-statusText:',config.xhr.statusText); 
    } 
}) 

返回:

XHR-ErrorHandle [錯誤,對象]

XHR-ErrorHandle狀態:

XHR-ErrorHandle-狀態文本:未找到