Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: SYNTAX_ERR: DOM Exception 12

I got the error 'Error: SYNTAX_ERR: DOM Exception 12' with this code:

var html = '<table><tr><td></td><td><input type="text" name="textArea" value="some text" /></td></tr></table>';
$(this.propertyContainer).html(html)

But NOT with this code:

$(this.propertyContainer).html('<table><tr><td></td><td><input type="text" name="textArea" value="some text" /></td></tr></table>')

Here is the html of propertyContainer:

<div xmlns="http://www.w3.org/1999/xhtml" class="property-grid" style="position: absolute; top: 35px; left: 0px;" id="ext-gen126"></div>

Do you have any idea?

like image 385
Charles Avatar asked Mar 12 '26 18:03

Charles


2 Answers

I found it. I forgot the character '/' at the end of the input tag...

I guess it's because of the dtd:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"
>

Sorry for that...

like image 151
Charles Avatar answered Mar 14 '26 09:03

Charles


No error here: http://jsfiddle.net/PA4Eg/

Possible mistake is one with the context, I guess (the meaning of this).

The source:

var obj = {
        propertyContainer: document.getElementById('ext-gen126')
    },
    html = '<table><tr><td></td><td><input type="text" name="textArea" value="some text" /></td></tr></table>';

$(obj.propertyContainer).html(html);
​

In the example bellow my source is the same:

var obj = {
        propertyContainer: document.getElementById('ext-gen126')
    },
    html = '<table><tr><td></td><td><input type="text" name="textArea" value="some text" /></td></tr></table>';

setHtml.call(obj, html);

function setHtml(html) {
    $(this.propertyContainer).html(html);
}
​

I use function to set the HTML content of the given div. For this function I use obj as context. It works again. I hope you'll fix your code by comparing it with the one above.

like image 37
Minko Gechev Avatar answered Mar 14 '26 07:03

Minko Gechev