Results 1 to 5 of 5

Thread: progress bar with php

  1. #1

    Question progress bar with php

    Hello all,

    Here is a small question for you...

    I've created a progress indicator with an ajax request, here is my code
    Code:
    var ajaxWaitMessage = null;
    
    Ext.Ajax.on({
        "requestcomplete": function(conn, response, options){
           
            
            // Hide AJAXWAIT -- added flag which checks for suppression 04/07/2009
            if (!options.suppressScreenLock && ajaxWaitMessage.isVisible()) 
            {
    			Ext.DomHelper.overwrite (ajaxWaitMessage, 
                        {html: 'Redirecting ...'},
                        true
                );
    			//window.location.replace("test.php");
    			
            }
    
        },
        "beforerequest": function (conn, options) {
            if (!options.suppressScreenLock)
            {
                if(!ajaxWaitMessage) {
                    ajaxWaitMessage = Ext.DomHelper.insertFirst(
                        document.body, 
                        {id: 'waiting_message'}, 
                        true
                    );
                    
                    Ext.DomHelper.append(ajaxWaitMessage, 
                        {html: 'Please wait" />'},
                        true
                    );
                }
                
                ajaxWaitMessage.show();
            }
        }
        
    });
    
    	Ext.Ajax.request({
    	   url: 'api.php?ac=test',
    	   timeout:9999999,
           success: function(responseObject) {
           alert(responseObject.responseText);
           },
           
    	   params: { id: '13' }
    	});
    
    });
    My code php is displaying message BEFORE the end of loading page with this code
    PHP Code:
    if (ob_get_level() == 0ob_start();

    for (
    $i 0$i<10$i++){

            echo 
    "<br> Line to show.";
            echo 
    str_pad('',4096)."\n";   

            
    ob_flush();
            
    flush();
            
    sleep(2);
    }

    echo 
    "Done.";

    ob_end_flush(); 
    Can you tell me how i can display during the ajax request the html output of the php file?

    Thanks for your help
    Christophe

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,447

    Default

    Well, the Ajax request is only going to poll your PHP script once.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2009
    Posts
    326

    Default

    Quote Originally Posted by mizzory View Post
    Well, the Ajax request is only going to poll your PHP script once.
    YOu beat me to it.

  4. #4

    Default

    Is there any other method i can use to print info from php?

    Thanks
    Christophe

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,247

    Default

    It's not worth the trouble. You're better off just showing a loading indicator.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •