0

I have a code which give the error unterminated string literal.
What is that error. Here is a code in which i am working.
I check console and the error is in $('#mydiv').append('\ in this line. Any suggestion. Thanks.

$('#mydiv').append('\
<TABLE cellpadding=0 cellspacing=0 class="t1">\
<TR>\
<TD class="tr1 td8"><P class="p13 ft13">T E S T</P></TD>\
<TD class="tr1 td9"><P class="p2 ft6">&nbsp;</P></TD>\
<TD class="tr1 td10"><P class="p14 ft13">RESULT</P></TD>\
<TD class="tr1 td11"><P class="p2 ft13">Cutoff</P></TD>\
<TD class="tr1 td11"><P class="p2 ft13">Patient</P></TD>\
</TR>\
<TR>\
<TD class="tr4 td12"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td13"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td14"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td15"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td15"><P class="p2 ft14">&nbsp;</P></TD>\
</TR>\                         
                       ');
0

2 Answers 2

1

Just do it like this:

$('#mydiv').append('\
<TABLE cellpadding=0 cellspacing=0 class="t1">\
<TR>\
<TD class="tr1 td8"><P class="p13 ft13">T E S T</P></TD>\
<TD class="tr1 td9"><P class="p2 ft6">&nbsp;</P></TD>\
<TD class="tr1 td10"><P class="p14 ft13">RESULT</P></TD>\
<TD class="tr1 td11"><P class="p2 ft13">Cutoff</P></TD>\
<TD class="tr1 td11"><P class="p2 ft13">Patient</P></TD>\
</TR>\
<TR>\
<TD class="tr4 td12"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td13"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td14"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td15"><P class="p2 ft14">&nbsp;</P></TD>\
<TD class="tr4 td15"><P class="p2 ft14">&nbsp;</P></TD>\
</TR>');

The penultimate line is not escaped so the error.

Sign up to request clarification or add additional context in comments.

1 Comment

This is not working I check the console and error is here <TABLE cellpadding=0 cellspacing=0 class="t1">\
1

You have a bunch of spaces after the \ on the penultimate line, so you have failed to escape the new line there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.