Re: innerHTML with AJAX problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robin

    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.getEle mentById("htmlT ext").innerHTML ;
    if(htmlDisp.len gth 10){
    document.getEle mentById("hidde nDiv").innerHTM L = 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
  • Martin

    #2
    Re: innerHTML with AJAX problem

    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.getEle mentById("htmlT ext").innerHTML ;
       if(htmlDisp.len gth 10){
               document.getEle mentById("hidde nDiv").innerHTM L = 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.

    Comment

    Working...