把它放在这里,就像在评论中一样,没有任何语法突出显示。
我在这里做了一个超级最小的测试页面:http: //www.focalstrategy.com/tests/ajax.php
代码是:
<?
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
echo date("F j, Y, G:i:s a");
exit();
}
?>
<!doctype html>
<html>
<head>
<title>AJAX test</title>
</head>
<body>
<h1>Ajax Test</h1>
<p>This page makes an AJAX request every 5 seconds and replaces the div below with the returned date.</p>
<div><p id="date"><?= date("F j, Y, G:i:s a") ?></p></div>
<div><p><span id="count">0</span> updates made.</p></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
var count = 0;
var getDate = function() {
$.get('/tests/ajax.php', function(data) {
$('#date').html(data);
count = count + 1;
$('#count').html(count);
});
}
setInterval(getDate, 5000);
</script>
</body>
</html>
所以,我跑了一个小时,没有任何问题,iPad(完全更新)在整个过程中运行良好,没有遗漏任何东西。
我也在 Chrome 上运行了它并记录了它的行为。这看起来像这样:
(全尺寸)
There's some weirdness here, in that at first the number of event listeners stays constant, then after a while goes mad,, increasing up to 56 listeners before dropping to 1 again. The DOM Node Count also repeatedly spikes, as high as 424. Both have fairly odd behaviour bearing in mind the simplicity of this code.
Perhaps on your app the number of Dom Nodes being tracked, or the number of event listeners is reaching some value causing the iPad to lose track of what's happening, or something similar.
It's also worth noticing that the memory usage ramps up until garbage collection happens. That's what is meant to happen, though perhaps it's less efficient on the iPad.
编辑:我在一个干净的配置文件上再次对其进行了测试,许多事件侦听器是由于扩展造成的——发生了相同的行为,但程度不同,背景值也是 0-1 而不是 15-20