Update page in a Simple Way

Asked

Viewed 2,653 times

0

I have an area on my site where you have the latest 5 news and I want to put a way to change this without manually. even with an Excel file, notepad or whatever.

   <div id="footer-wrapper">
            <section id="footer" class="container">
                <div class="row">
                    <div class="8u">
                        <section>
                            <header>
                                <h2>Últimas Noticias:</h2>
                            </header>
                            <ul class="dates">
                              <li>
                                    <span class="date">jan <strong>31</strong></span>
                                    <h3><a href="#">TESTE</a></h3>
                                    <p>Ipsum dolor sit amet veroeros consequat blandit ipsum phasellus lorem consequat etiam.</p>
                                </li>
                              <li>
                                    <span class="date">Jan <strong>23</strong></span>
                                    <h3><a href="#">Teste</a></h3>
                                    <p>Blandit phasellus lorem ipsum dolor tempor sapien tortor hendrerit adipiscing feugiat lorem.</p>
                                </li>
                              <li>
                                    <span class="date">Jan <strong>1</strong></span>
                                    <h3><a href="#">Ano Novo</a></h3>
                                    <p>Dolore consequat sed phasellus lorem sed etiam nullam dolor etiam sed amet sit consequat.</p>
                                </li>
                              <li>
                                    <span class="date">Dez <strong>25</strong></span>
                                    <h3><a href="#">Dia de Natal</a></h3>
                                    <p>Feugiat lorem dolor sed nullam tempus lorem ipsum dolor sit amet nullam consequat.</p>
                                </li>
                              <li>
                                    <span class="date">Dez <strong>13</strong></span>
                                    <h3><a href="#">teste</a></h3>
                                    <p>Feugiat sed tempus blandit tempus adipiscing nisl lorem ipsum dolor sit amet dolore.</p>
                                </li>
                            </ul>
                        </section>
  • How about doing a mini backoffice in PHP + HTML to change these fields?

2 answers

1

Hello, create a page with the contents to be updated, inside add:

     <head>
       <meta http-equiv="refresh" content="30">
     </head>

and on the main page add an iframe calling the page of the content in the region of the site that you want

  • The problem with meta refresh is that it will update the whole page and not just the news part.

  • wrong boy, the refresh will be on the separate page, will not change the content of the main page, only the iframe. make the test. in addition the solution would be simple as requested.

  • 1

    That’s right. I hadn’t read that you wrote to use the iframe. Sorry.

0

Ideally you would use websockets for real-time response but if you want to update every minute you can use the javascript setInterval() function and configure to make an ajax call every minute and update a <div> or the very <ul> with the content returned.

setInterval(function(){ /* chamada ajax aqui */ }, 60000);
  • PHP Long Polling would be better since it would be a request until it has a server response, while with the solution proposed above it would have to make requests even if there is no answer.

  • 1

    The ideal would be the web socket. long Polling is a way to simulate a web socket and is used in browsers that do not support html 5. Thank you for the comment.

  • 2

    Long Polling with the traditional technologies coming in the servers quickly depletes the web server threads. It ends up becoming a bigger problem than the "weight" of Ajax very fast.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.