Jump to content

PHP Start code after few seconds


alienphp

Recommended Posts

Hello, I need your help.

Im trying run code after few seconds (5s).

I tryed sleep() function, but the sleep function stop whole page for 5seconds.

I explain what to you what Im trying.

I have loading bar, loading for 5s.

for example:

 

<div class="loadingbar" style="--width: 10" data-label="Loading..."></div>

<?php

// After 5s I need start this code and hide loading bar in this page, without redirecting.

echo "sucesfully loaded" 

 

Is it possible, please? 

If yes, how to do?

If hiding the loading bar is not possible, how to just wait 5s for the code start? 

 

Many thanks!

 

 

Link to comment
Share on other sites

adding to Sir Barand's statements: if you cannot figure out the JavaScript code or you're too lazy to try, then you could use CSS 3 with animations which will show and hide a span inside your div.

I wonder, exactly how do you plan to fit the words "Successfully Loaded" into a 10 pixel div?

Link to comment
Share on other sites

  • 3 weeks later...

so you haven't replied in weeks . I assume based upon your post that you just want to remove the loading bar and display successfully loaded message, yes?

<html>
<head>
  <title>5 sec div</title>
  <style>
  @keyframes loading {
    from { opacity: 1; }
    to { opacity: 1; visibility: hidden; }
  }
  @keyframes loaded {
    from {opacity: 0;}
    to {opacity: 0;}
  }
  .loadingbar {
    max-width: 100px;
    border: solid 1px #c0c0c0;
  }
  .loading {
    animation: 5s linear loading;
    opacity: 0;
  }
  .loaded {
    animation: 5s linear loaded;
  }
  .load {
    position: absolute;
    top: 0 px;
    left: 0 px;
    padding: 8 px;
  }
  </style>
</head>
<body>

<div class="load loading loadingbar">Loading ...</div>
<div class="load loaded">Successfully Loaded</div>

</body>
</html>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.