2011-06-03 31 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-状态文本:未找到