我搜索到的一些帖子表明問題存在於由jquery處理的ajax中。我通過刪除所有ajax調用並遵循其他帖子所提示的使用$ ajaxSetup({cache:true})和其他方法進行測試,但其中沒有一個適用。我也嘗試完全刪除jQuery庫或我的腳本。 get請求的無限循環停止。具有下劃線和時間戳的無限網址
問題似乎存在於這段代碼中,其中all_posts [j] [0]是重新插入到文檔中的div元素。我嘗試在追加行之前和之後放置alert(j)。在放置之前,提醒的值與循環中預期的一樣,從0到6,並且由於無限循環的獲取請求而再次啓動。但是,當放置後,驚動了唯一的一點是0
for (var j = 0; j < all_posts.length; j++){
if (all_posts[j][3]){
$(".container").append(all_posts[j][0]);
}
}
下面是服務器日誌:
[05/Nov/2015 06:44:02]"GET /static/jquery.js?_=1446705842818 HTTP/1.1" 200 284394
[05/Nov/2015 06:44:02]"GET /static/ui/dist/js/vendor/video.js?_=1446705842819 HTTP/1.1" 200 66306
[05/Nov/2015 06:44:03]"GET /static/ui/dist/js/flat-ui-pro.js?_=1446705842820 HTTP/1.1" 200 1031693
[05/Nov/2015 06:44:03]"GET /static/jq-cookie/jquery.cookie.js?_=1446705842821 HTTP/1.1" 200 3121
[05/Nov/2015 06:44:03]"GET /static/top_js/myads.js?_=1446705842822 HTTP/1.1" 200 9521
[05/Nov/2015 06:44:03]"GET /static/jquery.js?_=1446705842964 HTTP/1.1" 200 284394
[05/Nov/2015 06:44:03]"GET /static/ui/dist/js/vendor/video.js?_=1446705842965 HTTP/1.1" 200 66306
[05/Nov/2015 06:44:03]"GET /static/ui/dist/js/flat-ui-pro.js?_=1446705842966 HTTP/1.1" 200 1031693
[05/Nov/2015 06:44:03]"GET /static/jq-cookie/jquery.cookie.js?_=1446705842967 HTTP/1.1" 200 3121
[05/Nov/2015 06:44:03]"GET /static/top_js/myads.js?_=1446705842968 HTTP/1.1" 200 9521
[05/Nov/2015 06:44:03]"GET /static/jquery.js?_=1446705843169 HTTP/1.1" 200 284394
不斷請求靜態腳本。 我使用Django及其開發服務器。 HTML片段被附加到的是:
<div class="row post">
<div class="col-md-8 col-md-offset-2 col-xs-10 col-xs-offset-1">
<div class="my-post-item">
<div class="my-post-item-inner">
<div class="my-post-item-inner-inner">
<div class="my-post-title">
<a href="#"><h4>{{post.title_line}}</h4></a>
</div>
<div class="my-post-description">
<p>{{post.description}}</p>
</div>
<div class="my-post-tags">
Tags:
{% for tag in post.tags.all %}
<span class="label label-warning">{{tag.text}}</span>
{% endfor %}
</div>
<div class="my-post-control button-group">
<button class="btn btn-success btn-secondary btn-xs btn-embossed">Edit</button>
<button class="btn btn-default btn-secondary btn-xs btn-embossed comments-button">Comments</button>
{% if post.shown %}
<button class="btn btn-warning btn-secondary btn-xs post-hide-button btn-embossed">Hide from Public</button>
{% else %}
<button class="btn btn-primary btn-secondary btn-xs post-show-button btn-embossed">Show for Public</button>
{% endif %}
<button class="btn btn-danger btn-secondary btn-xs post-delete-button btn-embossed">Delete</button>
</div>
<div class="my-post-info row">
<div class="col-xs-4 first-info-child">
<p class="first-post-time"></p>
</div>
<div class="col-xs-4">
<p class="last-modified-time"></p>
</div>
<div class="col-xs-4">
<p>Posted by: <br>{{post.poster.user_profile.first_name}} {{post.poster.user_profile.last_name}}</p>
</div>
</div>
<div class="hidden-id-info">
{{post.id}}
</div>
<div class="hidden-bg-img-info">
{{post.images.all.0.file.name}}
</div>
<div class="hidden-sorting-info" style="display: none">
<p class="last-modified-stamp">{{post.last_updated|date:"U"}}</p>
<p class="post-date-stamp">{{post.post_time|date:"U"}}</p>
<div class="hidden-popover-content" style="display: none">yap</div>
</div>
</div>
</div>
</div>
</div>
究竟是什麼*錯誤? – Sayse
腳本讓瀏覽器發送請求以獲取靜態腳本文件。永遠不要停止作爲我粘貼的服務器日誌。每個請求url都有參數?_ =一些時間戳。 @Sayse – seki