tags:

views:

22

answers:

1

Here i had use ajax, in which when ajax give response at that time it cut the text automatically after some characters (6140 characters), so is it limit of ajax respose? and if yes then how would be we can solve this?

If the string I am passing to javascript from jsp is too large javascript does not get it all the data. The magic number appears to be 6140 characters, anything below that it works fine, anything above and if I alert the ajax.response, I see the string is cutoff. Any ideas where this limitation is defined? how to solve this?

i had use pure ajax and learned from www.w3school.com, so just same like that i had use ajax and get respose in xml tag.

My code :

var XmlHttpRd = false; function CreateXmlHttpRd() { try { XmlHttpRd = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { try { XmlHttpRd = new ActiveXObject("Microsoft.XMLHTTP"); } catch(oc) { XmlHttpRd = new XMLHttpRequest();//for browser mozila, opera, firefox. } } }

function getAllChat() {
var requestUrl = "remotePage.jsp?r="+Math.random(); //alert(requestUrl); CreateXmlHttpRd(); if(XmlHttpRd) {
XmlHttpRd.onreadystatechange = HandleResponse; XmlHttpRd.open('GET', requestUrl, true); XmlHttpRd.send(null);
} }

function RefreshStatus() { if(refStatus) getAllChat(); }

function HandleResponse() { //alert(XmlHttpRd.readyState); //alert(XmlHttpRd.status); if(XmlHttpRd.readyState == 4 && XmlHttpRd.status == 200) { //alert(XmlHttpRd.responseText); // here i uncomment alert then respnse text seen cutofff var XmlRoot = XmlHttpRd.responseXML.documentElement;

            //// Some Code here to get data//////////
    }

}

please help me!!!

A: 

Are you sure the response is cut off and that it is not just the browser that does not show all text in the alert dialog? I have some Ajax requests that return very long exception traces that are displayed in an alert dialog and they are usually cut off by the browser somewhere. It is probably done to prevent a page from opening a alert dialog that would be too big for the screen.

If you want to get the full text you could add a <textarea id="debug"></textarea> to your page and use document.getElementById('debug').value = XmlHttpRd.responseText to get the full response.

I would recommend that you don't use a global XMLHttpRequest object because it could be overwritten when you start a second request. Then the onreadystatechange handlers of both requests could be executed and process the second request twice. You could do it like this:

function doRequest() {
    var request = new XMLHttpRequest();
    request.onreadystatechange = function() {
        if (request.readyState == 4) {
            if (request.status == 200 {
                // process response
            }
        }
    }
    request.open(...);
    request.send(...);
}

In this code every handler will access the request object that was defined in the function when the request was started and can not process a wrong request.

Reboot