473,387 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
0 1700

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lodge.stuart | last post by:
Hi I've written a small AJAX-style UI - although it's not strictly AJAX as it uses HTML fragments rather than XML This UI works fine for me and the majority of users. However, a few users...
9
by: Eric Wallstedt | last post by:
I have a page that "logs" changes made to input fields using ajax to pass data to a cgi. I use POST and it works fine most of the time (all the time in IE). But it fails when I get the data from...
6
by: Nico VanHaaster | last post by:
Hello all, I have run across an issue with IE 6.0+. I have a page that makes an XMLHttpRequest to the webserver to update a report on the page. The first time you hit the refresh report button...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
1
nmm32
by: nmm32 | last post by:
I am trying to use Ajax with JSP to populate a 2nd drop down list based on the chosen option of the first one. I am getting the error "Object Expected" on the line 13-14 of the HTML: <script...
2
by: rpollard | last post by:
Hi, I am relatively new to Ajax and am wondering if someone can shed a bit of light on the conceptual part of how Ajax handles its communication. Not knowing a whole lot about Ajax when I...
1
by: bgold12 | last post by:
I have a page that calls a javascript function every second using setInterval(): ... <body onload="setInterval('UpdateMessages(1);', 1000 );"> ... In UpdateMessages(), I create an AJAX...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.