wasn't quite sure how ask this, anyways. automatically adding divs (in php) depending on id's stored in array, , i'd refresh every existing div different value. here's example of divs like:
<div class="panel-heading" > <h4 class="panel-title" id="reload$device_id"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse$device_id">data: $device_data</a> </h4> </div>
i'm trying reload elements id "reload$device_id" (currently have 2 different id's, it'd reload1 , reload2).
thank help!
p.s: first time posting question, not sure how work
edit1: had <=device_id_list.length instead, quick typo fixed.
edit2: current code, pretty similar, reloads first 1 :/
<script type="text/javascript"> var device_id_list = <?php echo json_encode($device_id_list);?>; $(document).ready(function() { $.ajaxsetup({ cache: false }); // part addresses ie bug. without it, ie load first number , never refresh setinterval(function() { (var = 1; < device_id_list.length + 1; i++) { $("#reload" + i).load("reload_data.php?device=" + i); } }, 5000); }); </script>
its seems echo out json_encode($device_id_list)
, use php in javascript use device_id_list.length
in loop !! if i'm right .. can use
<script type="text/javascript"> $(document).ready(function(){ setinterval(function() { $('[div^="reload"]').each(function(){ $(this).load('reload_data.php'); }); }, 5000); }); </script>
hope help