jquery - Why am I getting this JS error? -


this error:

uncaught syntaxerror: unexpected token illegal d.d.extend.globalevaljquery-1.5.1.min.js:16 d.ajaxsetup.converters.text scriptjquery-1.5.1.min.js:16 bqjquery-1.5.1.min.js:16 vjquery-1.5.1.min.js:16 d.support.ajax.d.ajaxtransport.send.c 

here jquery:

$("div#notif_js").html(' ');  $("div#notification_box").html('<div class="notification">   <p><img alt="justin meltzer" class="feed_image_notif" src="/system/photos/46/tiny/justin meltzer.jpeg?1303109121" /> jmeltz     added comment <b>second</b> <img alt="justin meltzer" class="feed_image_notif" src="/system/photos/45/tiny/justin meltzer.jpeg?1303109101" /> justin meltzer</p>   <a href="/videos/506"></a> </div> <div class="notification">   <p><img alt="justin meltzer" class="feed_image_notif" src="/system/photos/46/tiny/justin meltzer.jpeg?1303109121" /> jmeltz     added comment <b>second</b> <img alt="justin meltzer" class="feed_image_notif" src="/system/photos/45/tiny/justin meltzer.jpeg?1303109101" /> justin meltzer</p>   <a href="/videos/506"></a> </div> <div class="notification">   <p><img alt="justin meltzer" class="feed_image_notif" src="/system/photos/46/tiny/justin meltzer.jpeg?1303109121" /> jmeltz     added comment <b>second</b> <img alt="justin meltzer" class="feed_image_notif" src="/system/photos/45/tiny/justin meltzer.jpeg?1303109101" /> justin meltzer</p>   <a href="/videos/506"></a> </div> <div class="notification">   <p><img alt="justin meltzer" class="feed_image_notif" src="/system/photos/46/tiny/justin meltzer.jpeg?1303109121" /> jmeltz upvoted bhbu </p>    <a href="/videos/505"></a>   </div>       <div class="notification">   <p class= "all_notifications">all notifications</p>   <a href="/videos/notification_go"></a> </div>'); 

javascript doesn't allow have multiple lines inside of strings. either need convert each line \n, so:

$("div#notification_box").html('line1\nline2'); 

or precede end of each line '\' so:

$("div#notification_box").html('line1\ line2'); 

the first method seems more commonly used, although second method looks better in opinion.

also, nice , easy way check javascript errors run through javascript delinter such http://www.javascriptlint.com/online_lint.php or http://www.jslint.com/ (although jslint doesn't report error nicely javascriptline).



Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -