Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Show Loading image while data gets loaded

23 views
Skip to first unread message

apoorv....@gmail.com

unread,
Aug 16, 2016, 11:41:56 PM8/16/16
to
Hello I am using a web service to fetch some data from another server I am running and based on the result I get I run foreach loop and show results.

Now I am using file_get_contents to fetch data Now It takes good 3-4 seconds for data to get loaded and the page seems to be loading.

I want to show a loading gif or a message that please wait and when I get result I want to show that.

I know we cab do that when we submit a form with beforesend function or show hide a gif but how would I do that with file_get_contents.

R.Wieser

unread,
Aug 17, 2016, 2:28:16 AM8/17/16
to
apoorv(?),

> I want to show a loading gif or a message that please wait and
> when I get result I want to show that.
>
> I know we cab do that when we submit a form with beforesend
> function or show hide a gif but how would I do that with
file_get_contents.

I'm not sure I understand the problem: you could place/echo some HTML before
executing the file_get_contents command, and that HTML should be displayed
on the clients webbrowser (it will display as much as it can, even when it
hasn't encountered the "</BODY>" and or "</HTML>" tags yet).

<?php
echo "<h3>Loading data, please wait</h3>";

$contents = file_get_contents(....);

echo "<h3>Finished loading, now processing data</h3>";

// do something with $contents here

?>

(untested, but should work)

Hope that helps.
Rudy Wieser


-- Origional message:
<apoorv....@gmail.com> schreef in berichtnieuws
dd778832-88ac-4924...@googlegroups.com...

Jerry Stuckle

unread,
Aug 18, 2016, 12:22:28 PM8/18/16
to
On 8/17/2016 2:30 AM, R.Wieser wrote:
> apoorv(?),
>
>> I want to show a loading gif or a message that please wait and
>> when I get result I want to show that.
>>
>> I know we cab do that when we submit a form with beforesend
>> function or show hide a gif but how would I do that with
> file_get_contents.
>
> I'm not sure I understand the problem: you could place/echo some HTML before
> executing the file_get_contents command, and that HTML should be displayed
> on the clients webbrowser (it will display as much as it can, even when it
> hasn't encountered the "</BODY>" and or "</HTML>" tags yet).
>
> <?php
> echo "<h3>Loading data, please wait</h3>";
>
> $contents = file_get_contents(....);
>
> echo "<h3>Finished loading, now processing data</h3>";
>
> // do something with $contents here
>
> ?>
>
> (untested, but should work)
>
> Hope that helps.
> Rudy Wieser
>
>
>

Rudy, what you are suggesting works in most browsers. But beware that
it is browser dependent (including browser version) and won't
necessarily work in all cases. It's also dependent on the HTML being
sent; i.e. a <table> without the matching </table> seems to fail to
display more than non <table> data.

But it varies widely.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

R.Wieser

unread,
Aug 18, 2016, 12:58:18 PM8/18/16
to
Jerry,

> Rudy, what you are suggesting works in most browsers.
> But beware that it is browser dependent (including browser
> version)

Alas, that (small differences) is always a problem with browsers. :-\

> It's also dependent on the HTML being sent; i.e. a
> <table> without the matching </table> seems to fail to
> display more than non <table> data.

Thats something I've seen too.

But agreed, its something the OP should be aware of.

Regards,
Rudy Wieser


-- Origional message:
Jerry Stuckle <jstu...@attglobal.net> schreef in berichtnieuws
np4nc0$oui$1...@jstuckle.eternal-september.org...

Härra Ramob

unread,
Jan 2, 2022, 6:50:20 AM1/2/22
to
ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ

ʕʘ̅͜ʘ̅ʔ
0 new messages