/    Sign up×
Community /Pin to ProfileBookmark

hangs on xmlhttp.responseXML.documentElement.getElementsByTagName("")

PLEASE help!!! This is driving me crazy …..

When I use the code:
var x=xmlhttp.responseXML.documentElement.getElementsByTagName(“ITM”);

the page hangs with no errors, but if I put an alert in front of the line:
alert(“”);
var x=xmlhttp.responseXML.documentElement.getElementsByTagName(“ITM”);

after clearing the alert the code runs perfectly.

Something to do with focus maybe??? I am so confuzed.

Thanks for any help with this,

Travis

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Oct 25.2009 — You are using xmlhttp before it is created. The alert works because by the time you have clicked on the alert, xmlhttp.responseXML has loaded. You need [url=http://www.tizag.com/ajaxTutorial/ajaxxmlhttprequest.php]onreadystatechange[/url].
Copy linkTweet thisAlerts:
@tschwarzauthorOct 25.2009 — I should have put the load info as well I am using onStateChange before the function is called.

[CODE]<script type="text/javascript">

var xmlhttp;

function loadXMLDoc(url)
{

xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=onResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);

creatediv();
}

function onResponse()
{
// alert("rs"+xmlhttp.readyState);
// alert("st"+xmlhttp.status);
if(xmlhttp.readyState!=4) return;

if(xmlhttp.status!=200)
{
alert("Problem retrieving XML data");
return;
}

}

function creatediv() {
alert("");
var a=0;
var x=xmlhttp.responseXML.documentElement.getElementsByTagName("ITM");
var wrapper = document.createElement('div');
wrapper.setAttribute('id', "wrapper");
document.body.appendChild(wrapper);[/CODE]
Copy linkTweet thisAlerts:
@tschwarzauthorOct 25.2009 — Also, I just found out the code hangs without the alert in chrome.

Travis
×

Success!

Help @tschwarz 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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