0

I am currently using this code to bring data into a <div>, it works however it's not a good user experience. I have to wait for this external file to be populated with data and then when it's finished then it pulls in the file. This sometimes can cause a 5 second delay. Meanwhile the user is starting at a white screen with a spinner.

<script>
$(function () {
    $(".viewdata").click(function() { 
        var cuser = document.genericform.guserid.value;
        var dataString = '&cuser='+ cuser;   
        var findDiv ="allproductsdiv";
        $.ajax({
            type: "POST",
            url: "inc/somefile.cfm",
            data: dataString,     
            cache: false,
            success: function(html){
                $('#'+findDiv).html(html);
            }
        });
    });
});
</script>

Is there a way to show data to the user while the data is streaming into a <div>?

George
  • 36,413
  • 9
  • 66
  • 103
user1322114
  • 317
  • 2
  • 10
  • Send the data from the server in chunks...index/number the data that is send like amoutOfDataSent/TotalData, and then send a request from the client again starting from the new offset, continue this till totaldata is received – Robin Rizvi May 09 '13 at 17:07
  • 1
    possible duplicate of [jQuery Ajax display data as it comes in](http://stackoverflow.com/questions/6093103/jquery-ajax-display-data-as-it-comes-in) and [jquery ajax, read the stream incrementally?](http://stackoverflow.com/questions/7740646/jquery-ajax-read-the-stream-incrementally) – j08691 May 09 '13 at 17:08
  • I don't think there's an easy solution, but take a look at the answers to this question: http://stackoverflow.com/q/7740646/900747 – A.M.K May 09 '13 at 17:11

0 Answers0