Obtain and Dispaly Partial Results readystate 3 ?

Discussion in 'JavaScript' started by DollaradeConner, Jul 19, 2008.

  1. #1
    Hi,

    I have a site that uses AJAX to fetch some results. At the moment, I'm only checking to see if readystate = 4, like this:

    function handleResults () {
    	result = document.getElementById('result');
    
    	if (xml.readyState == 4) {
    		if (xml.responseText == 'url.blank') {
    			result.innerHTML = 'Enter a valid URL';
    		} else {
    			result.innerHTML = xml.responseText;
    		}
    	} else {
    		result.innerHTML = 'Loading... <img src="ajax_loader.gif" />';
    	}
    }
    Code (markup):
    I tried changing it to if (xml.readystate >= 3), however it still does the same thing and shows the two column table with the results once it's completely done.

    How would I go about making it show each result as it came in?
     
    DollaradeConner, Jul 19, 2008 IP
  2. AdSpeed

    AdSpeed Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    "readyState=3 => Some data has been received. responseText is not available. responseBody is not available."

    Therefore, you cannot use responseText. If you would like to show one row each then should make only one row returned at a time and request the next
     
    AdSpeed, Jul 19, 2008 IP
  3. DollaradeConner

    DollaradeConner Active Member Affiliate Manager

    Messages:
    200
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I figured out how to do it. It requires you to use ob_start() and ob_flush() and a few other commands. You can find a small demo of it here: Domainjax which also has the source.
     
    DollaradeConner, Jul 20, 2008 IP