/    Sign up×
Community /Pin to ProfileBookmark

Ajax Chat Javascript Error

I Get some little errors when i use my ajax code:

Mozilla/Netscape Browsers give follow errors:

[CODE]
Error: uncaught exception: [Exception… “Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]” nsresult: “0xc1f30001 (NS_ERROR_NOT_INITIALIZED)” location: “JS frame :: http://192.168.1.15:83/scripts/chat-1.1.0.js :: chat_loadData :: line 61” data: no][/CODE]

[CODE]uncaught exception: [Exception… “Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]” nsresult: “0xc1f30001 (NS_ERROR_NOT_INITIALIZED)” location: “JS frame :: javascript: eval(__firebugTemp__); :: anonymous :: line 1” data: no] Line 0[/CODE]

[CODE]
// globale Instanz von XMLHttpRequest
var chat_xmlHttp = false;

// XMLHttpRequest-Instanz erstellen
// … für Internet Explorer
try {
chat_xmlHttp = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch(e) {
try {
chat_xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch(e) {
chat_xmlHttp = false;
}
}
// … für Mozilla, Opera und Safari
if (!chat_xmlHttp && typeof XMLHttpRequest != ‘undefined’) {
chat_xmlHttp = new XMLHttpRequest();
}

function getchatrooms()
{
if(document.getElementById(“chat_container”)) {
//alert(document.getElementById(“chat_container”).title);
// aktuelle Daten laden
chat_room_id = document.getElementById(“chat_container”).title;
chat_loadData(chat_room_id);
//alert(chat_room_id);

}
}

/* alle 5 Sekunden neue Daten holen
–> erweitert auf alle 8 sekunden */
getchatrooms();
setInterval(“getchatrooms()”,10000);

function chat_loadData(chat_room_id)
{
/* Check: DIV element exist */
if(document.getElementById(“chat_content_”+chat_room_id)) {
if (chat_xmlHttp) {
chat_xmlHttp.open(‘GET’, ‘chat.get.php?room=’+chat_room_id, true);
chat_xmlHttp.onreadystatechange = function () {
if (chat_xmlHttp.readyState == 4) {
/*if (chat_xmlHttp.readyState) {*/
document.getElementById(“chat_content_”+chat_room_id).innerHTML = chat_xmlHttp.responseText;
} else {
/*alert (chat_xmlHttp.readyState);*/
}

};
chat_xmlHttp.send(null);
}
}
}

function chat_saveData(chat_room_id)
{
if (chat_xmlHttp) {
chat_xmlHttp.onreadystatechange = ErrorMessagesChat;
chat_xmlHttp.open(‘POST’, ‘chat.post.php?room=’+chat_room_id);
chat_xmlHttp.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
chat_xmlHttp.send(‘room=’+chat_room_id+’&cid=’+document.chatbox.current_id.value+’&uid=’+document.chatbox.user_id.value+’&chatmessage=’+document.chatbox.chatmessage.value);
} else {
alert (“Could not POST”);
}

function ErrorMessagesChat() {
if (chat_xmlHttp.readyState == 4) {
if (chat_xmlHttp.status == 200) {
chat_error = chat_xmlHttp.responseText;
document.getElementById(‘chat_error’).innerHTML = chat_error;
} else {
alert(‘There was a problem with the request.’);
}
}
}

// Message-Eingabefelder leeren und Focus setzen
document.chatbox.chatmessage.value = ”;
document.chatbox.chatmessage.focus();
}
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Aug 20.2008 — Problem you are having is probably related to the fact you are reusing the Ajax object a previous request is not fully complete.

Eric
Copy linkTweet thisAlerts:
@netmaster4authorAug 20.2008 — sorry i don't find the fix to this error; can you try to fix it for me ?

thanks netmaster4
×

Success!

Help @netmaster4 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...