Jump to content

InnerHtml Alternative


sazzie

Recommended Posts


My Ajax application has stalled because Firefox responds to my innerHtml call but explorer doesn't.

My code is as follows :

[code]
[color=red]
var xmlDoc = request.responseXML;
var emailTag = xmlDoc.getElementsByTagName("email")[0];
var textOut = emailTag.firstChild.nodeValue;

document.getElementById(div_handler.divTag).innerHTML = textOut;
//document.getElementById("div1").appendData(textOut);
//document.appendData(textOut);
[/color][/code]

I tried using the DOM in the 2 last lines of code. I am sure one of them is wrong but the surprise is I can't get
the DOM to update my web page in either case.

Can someone please advice how to use the DOM to update my divs?

thanks
  :)
Link to comment
Share on other sites

it depends, if you're getting plain text from the server you can do it like this:
[code]
var txt = document.createTextNode(textOut)
document.getElementById(div_handler.divTag).appendChild(txt)
[/code]

if you need to process more complex info, you could send an array from the server, actually a string seperated by a "|" or something, then use the [b]split[/b] function in js to create an array, then process the data.

PS: innerHTML should work though, maybe you have a bug somewhere else..

Hope it helps. Cheers.
Link to comment
Share on other sites

I believe the innerHTML was invented by ie and is old and definitely works on ie(I use it all the time).  Things that are new like 'xmlDoc.getElementsByTagName' may not be supported by ie, however.

--try this test with a static value on ie:
[code]document.getElementById(div_handler.divTag).innerHTML = '**execution OK**';[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.