0

Say I have something like this:

    <div>
    <? require_once('include.php'); ?>
    </div>

Is there any way to have a loading animation until an included php script loads?

Thanks

user2743057
  • 169
  • 3
  • 5
  • 11
  • 2
    This mechanic includes a script on your server, during creation of the complete page. There can not be a loading icon as your page as a whole has not been loaded yet. To have such a loading icon, you need to include your snippet via a seperate call to your web server, possibly via AJAX as hinted in the answer. But your current mechanic can't work. – ToBe Sep 25 '13 at 12:49
  • Also note, that even if you change your application to use AJAX calls for it's includes, your PHP scripts won't run in the same context anymore. Depensind on whyt you are actually doing, you might need to do more than just change from PHP requires to AJAX includes... – ToBe Sep 25 '13 at 13:04
  • To clear things out so that some don't become overzealous in their pursuit of flagging questions, at the time of posting this I have already read the "jQuery “Please Wait, Loading…” animation?" question and couldn't find what I was looking for. – user2743057 Sep 25 '13 at 13:19

3 Answers3

3

PHP scripts don't "load", they're included on the server side and the user gets the final output of them. You need to read about the difference between server-side scripts and the client-side scripts.

Jakub Kania
  • 15,665
  • 2
  • 37
  • 47
1

Please see this link, it has what you need: Animated loading + Jquery with detailed instructions and explanations.

How can I create a "Please Wait, Loading..." animation using jQuery?

Community
  • 1
  • 1
  • Incomplete answer. The question shows all is loaded during initial page generation, not during a seperate web call that could be watched. – ToBe Sep 25 '13 at 12:50
  • You could implement the instructions, into a JS function. Example: LoadFile("include_me.php") - Which has the loading events. EDIT: See FaceofJock' answer, more or less what I meant, but didn't know there _was_ a specific Jquery function that could do such a thing. – RobAtStackOverflow Sep 25 '13 at 12:53
  • Yes, but judging from the initial question, I guess the OP is far away from any such solutions yet. ;) – ToBe Sep 25 '13 at 12:56
1

This can be done using ajax load method , in the client side :

$("div#hisId").slideUp("slow").load('include.php').slideDown("slow");
Charaf JRA
  • 8,249
  • 1
  • 34
  • 44