views:

303

answers:

0

Hi, I am creating an XMLHTTP object in Firefox and IE8 and i transfer a very large amount of data (json). In Firefox it renders it in 5 seconds, in IE8 it takes 30 seconds.

Is there any way to make IE8 XMLHTTP works faster?

Here is my code for creating the XHR object:

function createRequestObject2()
{
var http_request = false;
if(window.XMLHttpRequest)
{ //: Mozilla, Safari,...
    http_request = new XMLHttpRequest();
    if(http_request.overrideMimeType)
    {
        //: set type accordingly to anticipated content type
        //http_request.overrideMimeType('text/xml');
    }
}
else if(window.ActiveXObject)
{ //: IE
    try
    {
        http_request = new ActiveXObject("Msxml2.XMLHTTP.3.0");
    }
    catch (e)
    {
         try
        {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) { }
    }
}
if(!http_request)
{
    alert('Cannot create XMLHTTP instance');
    return false;
}

return http_request;
}

Here is how i use the XHR:

       http = createRequestObject2();
       http.open('GET', encodeURI(action), true);
            http.onreadystatechange = results;
            http.send(null);
            inwork = true;
            viewLoading();

            //: search results handling
            function results()
            {
                /*console.log("do_search.results[ " +
                        'Results return ' + http.readyState
                     + " ]"
                );*/
                if(http.readyState != 4)
                    return;

                inwork = false;

                if(http.status != 200)
                {
                    //setStatusLine(httpapplicant.statusText);
                    return;
                }

                //: evaluate
                var data = eval('(' + http.responseText + ')');

                //: add data to the table
                applicant_list = new dogtable(data, table1_options, $$('dog_results'));

                hideLoading();
            } //function results