Jump to content

Trying to get JS preloader to show before php is done


JohnnyDoomo

Recommended Posts

I'm attempting to use the preloader from here: https://www.niklausgerber.com/blog/preloadme-a-lightweight-jquery-website-preloader

 

My problem is that I have a line that includes a php file. This php line goes out and grabs rss feeds from other sites, and it takes roughly 10 seconds to process. My problem is, when using the above mentioned preloader, the page sits for the time it takes for the php to process, then quickly flashes the preloader, and then the site that uses the gathered rss info.

 

I don't know php or JS, but want to get this to work, so that the JS lines and page show, while that include statement is loading the php, and gathering the rss info.

 

Is there any easy way to do this, when I don't know php or JS?

 

Any help is greatly appreciated. Thanks!

Link to comment
Share on other sites

Is there any easy way to do this, when I don't know php or JS?

 

Short answer, No. You could either learn enough to accomplish what you want to achieve or find someone who will do it for you (possibly for a fee).

 

But, I can provide some insight as to the problem. When a request is made to a server for a PHP page, the server will complete all of the action within that script (and included scripts). Once all processing is complete it will then send the completed page to the user. There are a lot of exceptions to that, but for your situation it applies. Then once the user's browser receives the page, any JavaScript in that page can then execute.

 

The solution to your problem would likely be to make an AJAX call to get the RSS feed data. So, the page you have now should just create a container to put the RSS output and remove the PHP line that goes to get the content. Then, in addition to having JavaScript code to preload the images, you would implement an AJAX call to a PHP page to just return the RSS content that you would then populate on the page with JavaScript.

 

This may sound complicated, but there is a framework called JQuery that would make this rather easy. But, if you don't know any coding it could take a while to figure out how to implement it. http://api.jquery.com/load/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.