Hi all,
I have been wondering days long to find a solution to,
Ajax's error,
Error: [Exception... "Component returned failure code:
0x80040111
(NS_ERROR_NOT_AVAILABLE)
[nsIXMLHttpRequest.statusText]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location:
"JS frame ::
http://myhost:80/a
jax/ajscripts.js :: processStateChange :: line
131"
data: no]
Source File: http://myhost:80/a
jax/ajscripts.js
Line: 131
in my situation to print the result of a subscription
(weather
subscription was successful or failed) in the left pane of
my jsp page.
I used my call to server in the following way in my jsp
page.
<input value="Subscribe"
id="submit" type="submit" onclick =
"retrieveURL('SubscribeMail.do?name=subscriberReq',
'subscriberform');")
>
This transfer my request to ajax script where I am making
the
asynchronous call to my server.
var req;
function retrieveURL(url, nameOfFormToPost){
url=url+getFormAsString(nameOfFormToPost);
//Do the AJAX call
req = false;
if (window.XMLHttpRequest) {
try {
//Non-IE browsers
req = new XMLHttpRequest();
} catch(e) {
//alert("in catch for non IE");
req = false;
}
// branch for IE/Windows ActiveX version
}else if(window.ActiveXObject) {
try {
req = new
ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new
ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
if(req) {
//Set a function to be called after the response from the
server is
returned.
req.onreadystatechange = processStateChange;
req.open("POST", url, true);//open the
connection
setTimeout('processStateChange()',199);//ATTENTION
req.send(null); // make a call to the server
}
}// end of retrieveURL ?
That is by setting a timeout to my processStateChange
function
that will be processed after the XMLHttpRequest.status
becomes equal
to 200.
function processStateChange(){
if (req.readyState == 4) {// Complete
// alert("check");
var status = "";
try{
status = req.status;
}catch(e){//alert(" exception ");
status = "Trouble accessing it";
}
if (status == "ok" || status ==
"OK" || status == 200) { //alert("
OK response reached now we can process the response");
// alert("Ajax Response"+
req.responseText);
//Function to split the text response into Span elements
spanElements =
splitTextIntoSpan(req.responseText);
//Function to replace these span elements to update the
jsp page");
replaceExistingWithNewHtml(spanElements);
}
else {
alert("Problem with browser response:\n
Response status "
+ req.statusText);
}
}
}//processStateChange ends.
With this approach, I am getting the desired output.
Ofcourse with a non-recomended way of delaying response at
the client
end, by the use of set timeout().
Once again, if you uncomment the alerts, you will
notice that
the looping of setTimeout(processStateChange()',199) is not
stoped as
soon as the status == 200
Rather it continues to call back the function for a quite
larger no.
times, approximately 20.
even though this process does not take more than
seconds on my
system (local machine), when it is called by the use rit
might be
problematic.
Is this approach is acceptable or can any one give me
the issues
of setTimeout. Any links that I can find in.
Any suggestion welcome
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "JavaScript Forum" group.
To post to this group, send email to
JavaScript-Information googlegroups.com
To unsubscribe from this group, send email to
JavaScript-Information-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information
-~----------~----~----~----~------~----~------~--~---
|