如何设置ExtJS Ajax请求的超时设置之timeout属性

如何设置ExtJS Ajax请求的超时设置之timeout属性,第1张

ExtJS做Ajax请求的时候,默认的相应时间是30秒,如果后来数据查询时间超过30秒,ExtJS就会报错。

这就需要修改ExtJS的超时时间:在js开始时后加

示例代码如下所示:

view sourceprint?

1.Ext.onReady(function() {

2.Ext.BLANK_IMAGE_URL = '../../common/ext3/resources/images/default/s.gif '

3.Ext.Ajax.timeout = 180000 //设置请求超时时间(单位毫秒)

4.})

每个Ext.Ajax.request都有个属性

timeout : Number

The timeout in milliseconds to be used for this request. Defaults to 30 seconds.

普通的请求使用超时属性是这样

Ext.Ajax.request({

url: 'ajax_demo/sample.json',

success: function(response, opts) {

var obj = Ext.decode(response.responseText)

console.dir(obj)

},

failure: function(response, opts) {

console.log('server-side failure with status code ' + response.status)

},

timeout:3000000

})

store的请求则是这样

var myStore = Ext.create('Ext.data.Store', {

model: 'User',

proxy: {

type: 'ajax',

url: '/users.json',

reader: {

type: 'json',

root: 'users'

},

timeout:3000000

},

autoLoad: true

})

EXTJS 使用ajax回调后台数据

它的请求是有一个默认的超时时间的

超过这个时间 extjs就不会请求数据了

解决方法:优化SQL,分页查询,手动延长超时时间


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9649974.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存