468,302 Members | 1,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,302 developers. It's quick & easy.

Re: innerHTML with AJAX problem

Martin wrote:
Hello,

I have the following problem:

In a page I insert some HTML with a DIV by AJAX.
Whenever I try to insert other HTML into the content of this DIV by
using innerHTML it doesn't work.
But the strange thing is that after replacing the content of that DIV,
I can read the content and it tells me
the changed content (even though the browser doesn't show the changed
content)
I tested it with IE7 and Firefox and both browsers act the same.

Here is the code of the initial page:
[snip]
ajaxSimpleText(queryfile, 'htmlText');
....
var htmlDisp = document.getElementById("htmlText").innerHTML;
if(htmlDisp.length 10){
document.getElementById("hiddenDiv").innerHTML = htmlDisp;
[snip]

You appear to be putting the responseText into DIV 'htmlText' then
'hiddenDiv'. You therefore have two DIVs with id 'divslct4' (not legal
as IDs are supposed to be unique). Your code is changing (and reporting
that state of) the hidden one and hence the visible one isn't changing.

Robin
Jun 27 '08 #1
1 1277
On 9 mei, 12:23, Robin <a...@somewhere.comwrote:
Martin wrote:
Hello,
I have the following problem:
In a page I insert some HTML with a DIV by AJAX.
Whenever I try to insert other HTML into the content of this DIV by
using innerHTML it doesn't work.
But the strange thing is that after replacing the content of that DIV,
I can read the content and it tells me
the changed content (even though the browser doesn't show the changed
content)
I tested it with IE7 and Firefox and both browsers act the same.
Here is the code of the initial page:

[snip]
* ajaxSimpleText(queryfile, 'htmlText');
...
* *var htmlDisp = document.getElementById("htmlText").innerHTML;
* *if(htmlDisp.length 10){
* * * * * *document.getElementById("hiddenDiv").innerHTML = htmlDisp;

[snip]

You appear to be putting the responseText into DIV 'htmlText' then
'hiddenDiv'. You therefore have two DIVs with id 'divslct4' (not legal
as IDs are supposed to be unique). Your code is changing (and reporting
that state of) the hidden one and hence the visible one isn't changing.

Robin- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -
Thanks Robin,

I completely missed that point. As the htmlText is set to 'hidden', I
never realised it already contains the div id.
I used this temporary htmlText to check if it has been filled with
conent by AJAX. After is has been filled I put the content in the
hiddenDiv
which I set to show.

Thanks a lot, I feel quite stupid for not realising this.
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by sveinn | last post: by
8 posts views Thread by Clément | last post: by
4 posts views Thread by tcole6 | last post: by
17 posts views Thread by PJ | last post: by
5 posts views Thread by noddy | last post: by
4 posts views Thread by coby | last post: by
8 posts views Thread by Pratik Patel | last post: by
6 posts views Thread by rayliu | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.