JQuery Append Failing to Add Elements from String

I was building an HTML string and passing it to a JavaScript/JQuery method which appended the new HTML to an existing element. Pretty straightforward stuff, except it was not working. The HTML was created from a Razor View in MVC 3. There were no errors in the Razor View.

Frustrated I grabbed the HTML from the JavaScript debugger and pasted it into a new HTML page in Visual Studio. When I tried to reformat, I finally received errors that pointed me to some errant parentheses not found by Razor syntax checking.

In general, Visual Studio will not format anything it doesn’t like, so attempting to reformat can be a last ditch attempt to see whether the code, text, HTML or whatever is properly formed.

That’s not going to tell you whether the HTML is proper, because HTML issues generally come up as warnings. With the web page open though, you’ll get the warnings and you can explore how you messed up your HTML and confused JQuery. After I fixed the parens, I found that my logic for wrapping the form contents in a table was flawed.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>