给出致命错误:未捕获的异常' SmartyCompilerException'在模板中显示消息'语法错误

时间:2014-05-12 11:34:04

标签: smarty

这是我的代码,它给出了错误

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error 
      in template "C:\wamp\www\pangu\application\views\front\employer\lesson\topic_popup.tpl" on line 89
"$.post("{site_url()}("employer/library/show_topic");",{"id":id,"sts":sts},function(responseText){" - Unexpected ":", expected one of: "}" , " " , ATTR' 
      in C:\wamp\www\pangu\application\third_party\Smarty-3.1.13\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 665 

我是聪明的新人

   <script>
       function show_topic(id,sts){
           if($('#ch_'+id).is(":checked")) {
              sts =1;
           }
           else{
               sts = 0;
           }
           $.post("{site_url()}("employer/library/show_topic");"{"id":id,"sts":sts},function(responseText){});}
   </script>

2 个答案:

答案 0 :(得分:2)

在打开{literal}后使用function(),例如:

function init_map(){
    {literal}
    scripts
    {/literal}
}

答案 1 :(得分:0)

看来你的Smarty模板中有Javascript的问题。你应该这样做:

<script type="text/javascript"?
{literal}
// here you can put your javascript code safely
{/literal}
</script>

但在某些情况下,没有必要使用它们 - 请查看http://www.smarty.net/docs/en/language.function.literal.tpl