0
我有幾個div了與Ajax調用(這是MVC,但HTML看起來是這樣的,當它完成)更新:JQuery的組合每個使用Live
<div class="progresswrapper running" id = "ProgressWrapper1"></div>
<div class="progresswrapper running" id = "ProgressWrapper2"></div>
隨後的javascript:
<script type="text/javascript">
$(function() {
var timerid = window.setInterval(function() {
$('.progresswrapper.running').each(function() {
UpdateDivWithDataFromServer();
if(I'm done with this div) {
$(this).removeClass("running");
}
});
}, 500);
是否有可能以某種方式做到這一點?
使用[。對(http://api.jquery.com/on/),活已被棄用。 –
如果您希望我們解決錯誤,則必須提供'UpdateDivWithDataFromServer',removeClass必須在ajax調用的oncomplete方法中運行。 – mattmanser
除了使用加載內容或全局ajax事件的ajax請求的成功回調之外,您當前的代碼幾乎是唯一的方法。 '.live'和'.on'只對事件做出反應。使用ajax成功是處理它的最有效的方法。 –