简体   繁体   English

在属性列表之后丢失}

[英]missing } after property list

I am trying to implement a content slider using jQuery in one of my website; 我试图在我的一个网站上使用jQuery实现内容滑块; however I keep getting this error: 但是我一直收到这个错误:

missing } after property list

Here is my code: 这是我的代码:

<script type='text/javascript'>

featuredcontentslider.init({
id: 'slider1',  
contentsource: ['inline', ''],  
toc: '#increment',  
nextprev: ['prev', 'next'], 
revealtype: 'click', 
enablefade: [true, 0.1],  
autorotate: [true, 3000]
});
</script>

When I click on view source in Firefox I found that the last curly bracket is missing but in the file the code is fine, and using firebug debug console I got this error: 当我点击Firefox中的视图源时,我发现最后一个花括号丢失,但在文件中代码很好,并使用firebug调试控制台我收到此错误:

missing } after property list

I tried many things, searched for missing commas, eliminate most of the lines but could not find the source of the problem. 我尝试了很多东西,搜索了缺少的逗号,消除了大部分行,但找不到问题的根源。

EDIT: Firebug points to this line: 编辑:Firebug指向这一行:

});

as the one with error. 作为有错误的人。

I just checked the script in IE8, Chrome and firefox and in all of the three broweser i get the code like this: 我刚刚检查了IE8,Chrome和Firefox中的脚本,并且在所有三个浏览器中我都得到了这样的代码:

<script type='text/javascript'>

featuredcontentslider.init({
id: 'slider1',  
contentsource: ['inline', ''],  
toc: '#increment',  
nextprev: ['prev', 'next'], 
revealtype: 'click', 
enablefade: [true, 0.1],  
autorotate: [true, 3000]
);  <---- notice the missing bracket
</script>

I also tried to write one line only like so: 我也尝试只写一行:

featuredcontentslider.init({  id: 'slider1'  });

and still ended up with the same error. 并且仍然以相同的错误结束。 In localhost the script works fine, however in the actual website the script is functioning correctly. 在localhost中,脚本运行正常,但在实际网站中脚本运行正常。

I am wondering is there a possibility that other js code in the page might affect the behaviour of this one? 我想知道页面中的其他js代码是否有可能影响这个代码的行为?

Hmmm... this smells somewhat like a website cache error. 嗯......这闻起来有点像网站缓存错误。

Perhaps the } was missing at one time, and even though you fixed it, your website is still serving the old file. 也许}一次失踪了,即使你修复了它,你的网站仍在提供旧文件。

Have you tried: 你有没有尝试过:

  • clearing the cache in your browser? 清除浏览器中的缓存? (to see if it's browser-side) (看看它是否是浏览器端)
  • using curl or wget to view the raw javascript file (to see if there's a stale server-side cache) 使用curlwget查看原始javascript文件(以查看是否存在过时的服务器端缓存)

This usually happens, when a property list is accidentally closed by a ";". 当一个属性列表被“;”意外关闭时,通常会发生这种情况。 Take a look at the following example (which produces the same error): 看一下下面的例子(产生相同的错误):

$('#test').dialog({
    autoOpen: true,
    resizable: true,
    draggable: true,
    width:530,
    modal: true,
    closeOnEscape: true,
    show: {
        effect: 'blind',
        duration: 1000
    },
    hide: {
        effect: 'fold',
        duration: 1000
    });
});

The ); );; after

hide: { ... }); 

should be removed. 应该删除。

Ok I solved the problem by adding an extra curly bracket but I am not sure why that solved the issue. 好吧,我通过添加一个额外的花括号解决了这个问题,但我不确定为什么解决了这个问题。 My final script looks like this: 我的最终脚本如下所示:

<script type='text/javascript'>

featuredcontentslider.init({
id: 'slider1',  
contentsource: ['inline', ''],  
toc: '#increment',  
nextprev: ['prev', 'next'], 
revealtype: 'click', 
enablefade: [true, 0.1],  
autorotate: [true, 3000]
   } <--- notice the extra bracket
});
</script>

and it is cross-browser compatible :) 它是跨浏览器兼容的:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM