作者:董可芳妍_731 | 来源:互联网 | 2023-09-15 19:47
IamimplementingtheLDAalgorithmofTopicModellinginjavascriptasapartofaproject.Uponth
I am implementing the LDA algorithm of Topic Modelling in Javascript as a part of a project. Upon the click of a button, the function to perform LDA is called. However since this is a very heavy task, the browser used to hang for around 15 seconds when the function was called (even the loading animated gif wasn't working while processing was taking place).
作为项目的一部分,我正在用Javascript实现主题建模的LDA算法。单击按钮时,将调用执行LDA的函数。然而,由于这是一项非常繁重的任务,所以当调用该函数时,浏览器通常会挂起大约15秒(即使是正在处理的加载动画gif也无法工作)。
So I implemented the function as a web worker. This solves the hanging problem but now the loading animation disappears within a couple of seconds while the results are shown some 12-14 seconds after that.
所以我以web worker的形式实现了这个功能。这解决了挂起问题,但现在加载动画在几秒内消失,而结果显示在12-14秒之后。
Is there any way I can make the loader animate while the processing is going on ? I mean wait for the web worker to finish computing before the loading animation disappears.
在处理过程中,有没有什么方法可以让加载器动画?我的意思是在加载动画消失之前等待web worker完成计算。
The script is called asynchronously and the loader is attached to ajax events of jQuery as
脚本被异步调用,加载程序被附加到jQuery as的ajax事件上
$('#spinner').bind("ajaxSend", function() {
$(this).show();
}).bind("ajaxComplete", function() {
$(this).hide();
});
1 个解决方案