Adam Tourgeman
Adam Tourgeman

Reputation: 54

Trying to refresh div inside Iframe

I have a section of my site im working on where i have a certain div, the div "comments" needs to be checked for blank comments being posted and remove them, it works fine the first time but after the div is refreshed it stops working. I'm trying to get this script to reload every second along with the div so the results stay consistent. Here are my 2 scripts:

<script type="text/javascript">
function doRefresh(){
    $("#comments").load("comment.txt");
}
$(function() {
    setInterval(doRefresh, 1000);
});
</script>

<script>
setTimeout(refreshData, 1000);
function parent() 
{ $(".comment_name:empty").parent().hide()};
refreshData();
</script>

Upvotes: 0

Views: 62

Answers (1)

user9374996
user9374996

Reputation:

For future reference you should have a look into websockets. This will enable you to have data refresh as it is entered from one browser to another and will always keep it up to date without refreshing.

Here is a reference for you to get started. https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

It is a starting point and will help you a lot in future for dynamic content on multiple end points.

Upvotes: 0

Related Questions