-
Ajax NS_ERROR_NOT_AVAILABLE error
Hi Im having a **** difficult time with a ajax request. Basically i get the follow exception error on my firefox error console when I do an ajax request
Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost/trainingTools/ajax1.js :: anonymous :: line 64" data: no]
Source File: http://localhost/trainingTools/ajax1.js
Line: 64
this is the ajax code that i created:
Code:
function course_sec_id()
{
var courseRequest;
try{
// Opera 8.0+, Firefox, Safari
courseRequest = new XMLHttpRequest();
// trainingRequest.overrideMimeType('text/xml');
} catch (e){
// Internet Explorer Browsers
try{
courseRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e2) {
try{
courseRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e3){
// Something went wrong
alert("Your browser is not compatible!");
return false;
}
}
}
// alert('function start');
//browser support code
// The variable that makes Ajax possible!
//courseRequest = getHTTPObject();
//alert('ajax object created');
//object created
// Create a function that will receive data sent from the server
courseRequest.onreadystatechange = function(){
// alert('getting ready');
// alert('current state: '+ courseRequest.readyState);
//check http status. If not 200 (OK) then throw the status error code
if(courseRequest.readyState == 4)
{
if((courseRequest.status != 200)||(courseRequest.statusText != 'OK'))
{
alert(courseRequest.statusText);
}
else
{
alert('Please proceed!');
}
}
};
var securityID = document.getElementById('secid').value;
var course = document.getElementById('Name').value;
var cInst = document.getElementById('cIns').value;
var queryString = "secid=" + securityID + "&Name=" + course + "&cIns=" + cInst;
courseRequest.open("POST", "courseSecIdUpdate.php",true);
courseRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
courseRequest.setRequestHeader("Content-length", queryString.length);
courseRequest.setRequestHeader("Connection", "close");
courseRequest.send(queryString);
}
Basically what happens is that when this code is triggered through the following html:
[/code]
<form action="trainingformSubmit.php" onsubmit="course_sec_id();"
name="trainingForm" method="post" id="trainingForm">
[/code]
The ajax function does not process when readystate is 4 ( I do not get any of the alert messages).
However, get this, if i add the highlighted line from above aajx code:
Code:
alert('get ready');
The whole process works..
This is really confusing. overall all of the code not work at all in safari. Works with exceptions in firefox, works well as it is in IE6,7.
PLEASE HELP!!! this is a BRAIN Killer!
-
The root cause of this error is that the value courseRequest.status or courseRequest.statusText is not available. The W3C standards mandate that an error be thrown in such cases, when you try to read it!! This is quite unusual because JavaScript customarily returns undefined or "" on such cases (sometimes I just hate W3C, but I guess they have their reasons). Try removing the check for courseRequest.statusText or, if it still doesn't work, both courseRequest.statusText and courseRequest.status. That will most probably fix the issue.
Similar Threads
-
By rajithakba in forum AJAX
Replies: 2
Last Post: 04-20-2008, 05:50 AM
-
By Chris H Baker in forum C++
Replies: 5
Last Post: 01-17-2007, 02:37 PM
-
By clarence_rollins in forum .NET
Replies: 21
Last Post: 09-11-2002, 11:32 AM
-
By Khalizan in forum VB Classic
Replies: 1
Last Post: 11-28-2001, 02:32 AM
-
By Tom Shreve in forum Enterprise
Replies: 0
Last Post: 04-07-2000, 09:19 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|