I have two functions in my script, one that outputs some long HTML string, the other one that takes this string as a parameter and processes it.
function myFirstFunction() {
//output some HTML
return myHTML;
}
var myHTML = myFirstFunction();
function mySecondFunction(myHTML) {
//do something with parameter
}
For some reason that I can't figure out, the Chrome JS Console keeps giving me the following error: "Uncaught SyntaxError: Unexpected token <"
I thought maybe that was due to the fact, that the outputed HTML was pretty long since it seems to be working with small chunks of HTML. Any thoughts? Thx!
Here's problem:
myHTML is a HTML string like this:
var myHTML ="<div id="foo"><div id='hello'>hello</div><div id="bar">bar'asdf'asf"sdf"&soidf;</div></div>";
That won't work because you have quotes and stuff inside it that are NOT escaped.
If you used innerHTML to get the HTML of an element on the page, this wouldn't be a problem.
myHTML is constructed with some < or > extra so verify the html string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With