Uncaught SyntaxError:我网站上的意外标识符

时间:2015-07-24 12:52:22

标签: javascript jquery

我在第5行的chrome'Uncaught SyntaxError:Unexpected identifier'中得到了这个。我无法弄清楚什么是错的。任何人都可以帮忙。

<script type="text/javascript">
            jQuery(function(){
            jQuery("body").block(
                {
                    message: "<img class="lazy lazy-hidden" src="data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=" data-lazy-type="image" data-lazy-src=\"https://example.com/wp-content/plugins/woocommerce/assets/images/ajax-loader.gif\" alt=\"Redirecting…\" style=\"float:left; margin-right: 10px;\" /><noscript><img src="https://example.com/wp-content/plugins/woocommerce/assets/images/ajax-loader.gif" alt="Redirecting…" style="float:left; margin-right: 10px;" /></noscript>Thank you for your order. We are now redirecting you to Payment Gateway to make payment.",
                        overlayCSS:
                {
                    background: "#fff",
                        opacity: 0.6
              },
            css: {
                padding:        20,
                    textAlign:      "center",
                    color:          "#555",
                    border:         "3px solid #aaa",
                    backgroundColor:"#fff",
                    cursor:         "wait",
                    lineHeight:"32px"
            }
            });
            jQuery("#submit_payment_form").click();

            });
          </script>

2 个答案:

答案 0 :(得分:2)

语法高亮显示非常清楚,您关闭带引号的字符串,然后继续使用字符串:

message: "<img class="lazy lazy-hidden" src="data:ima...

解释器将lazy视为标识符,并因为没有此类标识符而抛出错误。修正你的报价:

message: '<img class="lazy lazy-hidden" src="data:ima...

答案 1 :(得分:0)

你需要转义斜杠/////或者它会被识别为语法错误,因为//是javascript中的注释

http://www.w3schools.com/js/js_strings.asp