0
我正在写一个GreaseMonkey脚本。我发现一些元素是由ajax加载的。 当我的用户脚本运行时,数据未加载。 我尝试使用'while'等待ajax加载数据,结果是浏览器被锁定并在以后崩溃。 如何在GreaseMonkey脚本中等待由ajax加载的数据?我的GreaseMonkey脚本如何获取稍后将由ajax加载的数据?
我正在写一个GreaseMonkey脚本。我发现一些元素是由ajax加载的。 当我的用户脚本运行时,数据未加载。 我尝试使用'while'等待ajax加载数据,结果是浏览器被锁定并在以后崩溃。 如何在GreaseMonkey脚本中等待由ajax加载的数据?我的GreaseMonkey脚本如何获取稍后将由ajax加载的数据?
setTimeout(function () {
if (data){
// if loaded
// do something
} else {
// wait a moment and check again
setTimeout(arguments.callee , 500);
}
} , 500);
谢谢!它工作正常。 – user1260771 2012-03-10 10:37:01
@ user1260771,如果这个答案为你做了,请[标记为已接受](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) 。 – 2012-03-10 21:49:40