我正在使用Prototype框架的Ajax.Responders.register注册每个Ajax调用。想法是在请求打开时呈现Ajax Spinner。 但是当一个请求只需要一些毫秒时,我就不会显示ajax微调器。但是因此我需要请求的参数来检查参数中的标志。
实际实现的代码段粘贴在下面。
var Ajax;
if (Ajax && (Ajax != null)) {
Ajax.Responders.register( {
onCreate : function(transport) {
console.log("Test");
console.log("Parameters: " + transport);
if (Ajax.activeRequestCount > 0) {
Effect.Appear('loading', {
duration : 0.5,
queue : 'end'
});
//new Effect.toggle('loading', 'appear');
new Effect.Opacity('page', { from: 1.0, to: 0.3, duration: 0.7 });
Mask.centerSpinner('loading');
}
},
onComplete : function() {
if (Ajax.activeRequestCount == 0) {
Effect.Fade('loading', {
duration : 0.5,
queue : 'end'
});
//new Effect.toggle('loading', 'appear');
new Effect.Opacity('page', { from: 0.3, to: 1, duration: 0.7 });
}
}
});
}
答案 0 :(得分:0)
我找到了解决方案:
var Ajax;
if (Ajax && (Ajax != null)) {
Ajax.Responders.register( {
onCreate : function(transport) {
if (Ajax.activeRequestCount > 0 && transport.options.parameters.disabledAjaxSpinner==undefined) {
Effect.Appear('loading', {
duration : 0.5,
queue : 'end'
});
//new Effect.toggle('loading', 'appear');
new Effect.Opacity('page', { from: 1.0, to: 0.3, duration: 0.7 });
Mask.centerSpinner('loading');
}
},
onComplete : function(transport) {
if (Ajax.activeRequestCount == 0 && transport.options.parameters.disabledAjaxSpinner==undefined) {
Effect.Fade('loading', {
duration : 0.5,
queue : 'end'
});
//new Effect.toggle('loading', 'appear');
new Effect.Opacity('page', { from: 0.3, to: 1, duration: 0.7 });
}
}
});
}