/    Sign up×
Community /Pin to ProfileBookmark

processReqChange in IE being called only once

I putted alerrt in loadXMLDoc(url) function and the request was sent every time it was needed.
I putted alert in processReqChange() with no conditions and noticed it’s being called only once in IE.
Is this some bug I don’t know about or you need the code?
Everything works well in FF & opera.
Thanks ahead.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Aug 10.2007 — What is the exact code you are using?

Eric
Copy linkTweet thisAlerts:
@valenokauthorAug 10.2007 — [CODE]

<table><tr>
<td style="border:1px solid #7F9DB9;" valign='top'>
<textarea id='txt' rows='10' cols='50' onkeyup='checkwords()' wrap='soft' class='text'></textarea></td>

<td valign='top' id='menu' class='menu' style="visibility:hidden;">

</td></tr></table>

[/CODE]



[CODE]
<SCRIPT language="JavaScript" type='text/JavaScript'>


try { req = new XMLHttpRequest(); }
catch (trymicrosoft) {
try { req = new ActiveXObject("Msxml2.XMLHTTP");}
catch (othermicrosoft) {
try {req = new ActiveXObject("Microsoft.XMLHTTP");}
catch (failed) {req = false; }

}
}




// Sen the request
function loadXMLDoc(url){
if (!req) return false;

req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
}



// Working out the response
function processReqChange(){
if (req.readyState != 4 || req.status != 200 ) return false;
if(req.responseText.length<10) { document.getElementById('menu').style.visibility = 'hidden'; return false; }
document.getElementById('menu').style.visibility = 'visible';
document.getElementById('menu').innerHTML = req.responseText;
}


// Finds out the word for auto-completing
function checkwords()
{
var text = document.getElementById('txt').value;

pos = false;
if(text.charCodeAt(text.length)==32 || text.charCodeAt(text.length)==10) return true;

for(i = text.length;i>0;i--)
if(text.charCodeAt(i)==32 || text.charCodeAt(i)==10) { pos = i+1; break;}
var word = text.substr(pos);


// Input mode
if(word!='') loadXMLDoc("<?php echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];?>?q=" + word);

}



isOpera=window.opera; //Opera 5+
isMSIE=document.all&&document.all.item&&!isOpera; //MSIE 4+
isMozilla=navigator.appName=="Netscape"; //Mozilla




var menu = document.getElementById('menu');
menu.onmouseover = menu.onmouseout = menu.onclick = function(e)
{
if (!e) e = window.event;
var elem = e.target || e.srcElement;

if(elem.tagName!='SPAN') return false;

if(e.type=="mouseover") {
if(!isMSIE) elem.setAttribute('class','menu_item_hover');
else elem.className = 'menu_item_hover';
}
if(e.type=="mouseout") {
if(!isMSIE) elem.setAttribute('class', 'menu_item');
else elem.className = 'menu_item';
}
if(e.type=="click")
{ if(isMSIE) pos--;

document.getElementById('txt').value = document.getElementById('txt').value.substr(0,pos) + elem.innerHTML + " ";
if(isOpera){
var t = document.getElementById('txt');
t.setSelectionRange(t.value.length, t.value.length);
}
document.getElementById('txt').focus();
document.getElementById('menu').style.visibility='hidden';

}

}


[/CODE]
Copy linkTweet thisAlerts:
@A1ien51Aug 10.2007 — You need to swicth this
<i>
</i> req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);

to this:

req.open("GET", url, true);
req.onreadystatechange = processReqChange;
req.send(null);


Eric
Copy linkTweet thisAlerts:
@valenokauthorAug 10.2007 — Yesterday I tried for two hours fix it without any result.

Thanks a lot..
×

Success!

Help @valenok 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.1,
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,
)...