Start New Discussion within our Web Development Community

hi friends

i have develpoed a prog. for pay calculation for my office in php.
now i want to show some thing like employee name in my pge which is currently processing or progress bar with persent if calcution has done.
plz note i m useing POST methord

I have saved code snipped with flush:

PHP updating page when function is not finished
Tested, works. But does not work when fiddler is running.

public function index() {

        if (ob_get_level() == 0) {
        echo str_pad('Loading... ',4096)."<br />\n";
        $d = 0;
        for ($i = 0; $i < 25; $i++) {
            $d = $d + 11;
            //This div will show loading percents
            echo '<div class="percents">' . $i*4 . '%&nbsp;complete</div>';
            //This div will show progress bar
            echo '<div class="blocks" style="left: '.$d.'px">&nbsp;</div>';

Clear screen when using this way of page updating:
private function clr_scr() {
        echo "<script type='text/javascript'>\n";
        echo "document.body.innerHTML = ''";
        echo "</script>";

This is not ajax, but you can use it.

Not sure how this would work with ajax, havent' tried.

I'm not sure what you really want but try this.

In your JavaScript code, submit the name of your employee via form and perform an ajax call so as to not refresh the page.

jquery framework (widely used js framework that rocks!) -
jquery ujs so as to handle all ajax calls across your site -


<form action="youraction" method="post" id="form-id" "data-remote" => "true">
<input type="text" name="employee_name"/>
<div id="loader"></div>    
<button type="submit">Submit</button>

<div id="employee-data"></div>


$(document).ready(function() {

  // ajax:before is executed upon submitting your form
  // you can insert a loader here or do some validation before sending your ajax call  
  $('#form-id').on('ajax:before', function() {
    // put your code here

  // ajax:success runs when the server returns a successful call
  // display the data returned by your server here
  $('#form-id').on('ajax:success', function(event, data) {
    // put your code here
    // data depends on what kind of data your server responds (json or html format)

    // hide your loader


sorry to responce so late, my problem was solved through the code given by "SPeed_FANat1c"
but I would like to thanks to both of u along for the greate help . thank u to all

This question has already been answered. Start a new discussion instead.