Jquery html() doesn't work for me, but innerHTML() do?

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


14 points

Hello all:

I've a form working with the form plugin. It works fine. I have the next
callback method:

function showResponse(responseText, statusText){
        alert(responseText);
        $('#frameBody').html(responseText);
        alert ($('#frameBody').html());
 
}

When the showResponse() method is invoked, the first alert() shows something
like that:

<div>
 
    <spann>buttons</spann>
    <div id="myDiv">
        <div id="errorsDiv">
             <html:errors />
        </div>
        <spann>Main Page</spann>
    </div>
</div>

(I have intentionally changed the "span" tag to "spann", in order to show
this post correctly)

As you can imagine, this code is generated by a jsp page, in a struts
framework.
The surprise comes with the second alert():

<SPANN>Main Page</SPANN>

Where is the rest of the code? If I change :
$('#frameBody').html(responseText);

to
document.getElementById("frameBody").innerHTML = responseText;

it works fine!!!!. What is happening? Must I use the old fashioned way ?

This is only a jquery proof of concept, but it is worrying me... Any idea?



13 points

I've solved my problem. The jsp that generates the html was not including the
struts html taglib, and the element "" wash crashing the
jquery.

Anonymous's picture
Created by Anonymous

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.