By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

After making a AJAX request from .js file the readystate propertyof the Http object is not changing (remains constantly @ 1)

P: n/a
Hello,

Once the AJAX request is fired the readystate property remain as 1. It
never gets changed and the callback method is not firing as a result the
..aspx page is not being rendered.

The two functions that is involved in the above mentioned issues are
placed below:

fn #1

function ajax_SendRequest(fullUrl, callback)
{
var xmlHttp = CreateXmlHttpObject();

var url = fullUrl.split('?')[0];
var params = fullUrl.split('?')[1];

//Use post method in case data send to server exceed limit.
xmlHttp.open("POST", url, /* async = */ true);
xmlHttp.onreadystatechange = function() {
_ajax_HandleResponse(xmlHttp, callback); setCursorToArrow();}

xmlHttp.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

if (currentXmlHttp != null)
{
pendingRequests.push(xmlHttp);
pendingRequestsContent.push(params);
}
else
{
currentXmlHttp = xmlHttp;
xmlHttp.send(params);
}
}

fn #2

function _ajax_HandleResponse(xmlHttp, callback)
{

if (xmlHttp.readyState != 4)
{
// Not finished yet; do nothing
}
else if (xmlHttp.status != 200)
{
if( xmlHttp.status != 0 ) // Not aborted
{
_ajax_ReportError("AJAX request failed with HTTP code " +
xmlHttp.status + " : " + xmlHttp.statusText);
}
}
else
{
var dom = xmlHttp.responseXml;
var err = dom.parseError;

if (err.errorCode != 0)
{
_ajax_ReportError(err.reason + "\nXML context: " +
_ajax_FocusSubString(err.srcText, err.linepos));
}
else
{
var root = xmlHttp.responseXML.selectSingleNode("root");

if (! root)
{
_ajax_ReportError("XML was valid but did not have the expected
'root' document element");
}
else
{
_ajax_UnpackResponse(root);
if(root.selectSingleNode('content') &&
root.selectSingleNode('content').attributes.getNam edItem('ErrorCode'))
callback = null;

if (callback)
{
callback(root);
}

var fn = document.body.onresize; // Yes, we have to alias this.
No, we don't know why.
if (fn) fn();
}
}
}
if (pendingRequests.length 0)
{
currentXmlHttp = pendingRequests.shift();
currentXmlHttp.send(pendingRequestsContent.shift() );
}
else
{
currentXmlHttp = null;
}
}
Thanks,
Mathan.
Sep 19 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.