0

I have found an issue while searching the data.

I have one file (search.php) that is input data from the user and submit the form data the other PHP file (results.php).

In the Results.php file I wrote a jQuery function :

<script>
    function loader(new_val){
       console.log(new_val);
    }
</script>

I include multiple file in results.php like :

<?php 
    include('demo1.php');

    include('demo2.php');

    include('demo3.php');
?>

Now I need to call the jQuery function :

  1. After "demo1.php" included call jquery loader(4);

  2. After "demo2.php" included call jquery loader(8);

  3. After "demo3.php" included call jquery loader(12);

For example:

include('demo1.php');
echo "<script>loader(4);</script>";
include('demo2.php');
echo "<script>loader(8);</script>";

Like this but when I perform this kind of operation it's not working so I can't update the progress bar value.

It updates the value after whole PHP file executes so would you please let me know how can I call jQuery function loader() after include the file one by one.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dhaval
  • 89
  • 2
  • 11
  • 1
    This can not work, because the webserver will in most cases execute the whole PHP scipt (with all includes), before sending the resulting HTML page to your client. – Erik Kalkoken Feb 06 '18 at 14:42
  • Not sure what you want to do here, but you need to completely rethink your architecture. e.g. control loading by javscript making AJAX calls to several PHP scripts. – Erik Kalkoken Feb 06 '18 at 14:44
  • Surely if you are php including the files, the page doesn't render until all the files have been included anyway. Your best bet is to ajax in each include and on success run the loader function. – Pete Feb 06 '18 at 16:33

0 Answers0