1

My html contains different images, without any legality - all located under some table. For example homepage.htm:

<table id="imagesTable">
    <tr>
        <td>
            <img src="img1.png">
            <div>
                <img src="img2.png">
            </div>
        </td>
        <td>
            <div>
                <div>
                    <img src="img3.png">
                </div>
            </div>
        </td>
    </tr>
</table>

The images sources in this page can be different every time I'm getting the page (but all other elements structure stays as is) and I want to update the page every 5 sec and update the new images instead of the old one (without refreshing the page). I tried to implement it with the following approach (without success):

function updatePage()
{
    $("#imagesTable").load("homepage.htm #imagesTable");
    window.setTimeout("updatePage()",5000);
}
...
<body onload="updatePage();">
....

any idea what I'm doing wrong? any other suggestions how to solve this issue?

4
  • Use setTimeout(updatePage,5000); instead. Do you have any errors? Commented Nov 17, 2013 at 7:25
  • Could it be a browser caching problem? It would make a big difference if you told us what the problem actually is? Commented Nov 17, 2013 at 7:26
  • Currently the existing images elements do change - but the new one don't (new images can be added into the table..) Commented Nov 17, 2013 at 12:27
  • + it's doesn't work on IE7 (I'm using jQuery 1.8.6) Commented Nov 17, 2013 at 12:55

2 Answers 2

1

Replace:

$("#imagesTable").load("homepage.htm #imagesTable");
window.setTimeout("updatePage()",5000);

With:

$("#imagesTable").load("homepage.htm #imagesTable *");
window.setTimeout(updatePage,5000);
Sign up to request clarification or add additional context in comments.

2 Comments

Doesn't help :( what does the asterisk stands for?
@ItayB: * stands for all types of children. It means we get only the children of #imagesTable
0

I came across my question again, so I'll add a short answer - my solution to the problem:

These images purpose was to indicate some of the system status; thus, I decided to separate the view and the data (MVC) and I've added JSON with the statuses state, which is called every 5 seconds (via ajax). Now in the client I've recreated the relevant DOM sections with the new images - which are suitable to the new system status.

Hope that's will help someone in the future :-)

Cheers!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.