---
title: "How to set delay in a set Interval loop?"  
description: "How to set delay in a set Interval loop?"  
author: "Anonymous User"  
published: 2013-05-03  
updated: 2013-05-03  
canonical: https://www.mindstick.com/forum/794/how-to-set-delay-in-a-set-interval-loop  
category: "javascript"  
tags: ["javascript"]  
reading_time: 2 minutes  

---

# How to set delay in a set Interval loop?

Hi Everyone!\
Here is part of my codes:\

```
$('#monitor').click(function(){            setInterval(function(){                    $('#status_table tr [id^="monitor_"]:checked').each(function () {                        monitoring($(this).parents('tr'));                     });                },15000);        });
```

I want to call the [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) [monitoring](https://www.mindstick.com/articles/12832/learn-the-art-of-monitoring-google-updates-to-stay-in-tune-with-the-best-seo-practices) for each [row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) in a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) that has its [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net) checked. if i only have one, it is [working fine](https://answers.mindstick.com/qa/95550/why-is-the-safari-browser-not-working-fine). But when i have more than one, \
it jumbles up, which means it will not append the correct [status](https://www.mindstick.com/articles/157184/check-lic-policy-status-online-by-policy-number) in the table. Here is my function monitoring:\

```
       function monitoring($row) {            fbType = $row.find('td:nth-child(3)').html();            fbNum = $row.find('td:nth-child(4)').html();            eachStatus =$row.find('td:nth-child(5)').attr('id');            $('#ptest').append(fbType + ' '+ fbNum+' '+ eachStatus +'<br>');            $.post('/request', {inputText: fbNum,key_pressed: fbType.toString()}).done(function (reply) {                if (reply == "on") {                    $('#status_table tr #'+eachStatus).empty().append("on");                } else if (reply =="off") {                    $('#status_table tr #'+eachStatus).empty().append("off");                }            });        }
```

How can i delay the function call for each row? i tried the following\

```
       $('#monitor').click(function(){            setInterval(function(){                    $('#status_table tr [id^="monitor_"]:checked').each(function () {                       setTimeout(function(){                            monitoring($(this).parents('tr'));                       });                     });                },15000);        });
```

But the div #ptest displays undefined.\
Please help me!

## Replies

### Reply by AVADHESH PATEL

Hi Ankita!\
Replace your following line:\
monitoring($(this).parents('tr'));for this one:\
monitoring($(this).parent('tr'));\
I hope it resolve your problem!


---

Original Source: https://www.mindstick.com/forum/794/how-to-set-delay-in-a-set-interval-loop

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
