HighTechTalks DotNet Forums  

After Sending an AJAX request the value of the readystate propertyis not changing.

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss After Sending an AJAX request the value of the readystate propertyis not changing. in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mathan Babu
 
Posts: n/a

Default After Sending an AJAX request the value of the readystate propertyis not changing. - 09-19-2006 , 05:07 AM






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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.