$.post 错误怎么回事?
$(function(){ $('#bn').click(function() { var r = []; $('.xh').each(function(i, t) { r.push($(this).html()); }); alert(r); $.post("yidong.php",{xh :r}); });});[code=php]<table class="result-tab" width="100%" cellspacing="0"> <tr align="center"> <td align="center"><h2>编号</h2></td> <td><h2>名 称</h2></td> <td><h2>种 类</h2></td> <td><h2>类 别</h2></td> <td><h2>图 片</h2></td> <td><h2>简 介</h2></td> <td><h2>图 示</h2></td> <td><h2>介 绍</h2></td> <td><h2>公 司</h2></td> <td><h2>开 始</h2></td> <td><h2>结 束</h2></td> <td><h2>地 址</h2></td> <td><h2>休 息</h2></td> <td><h2>网 址</h2></td> <td><h2>停 止</h2></td> <td><h2>操 作</h2></td> <td><h2>排 序</h2></td><td><h2><td></td></h2></td> </tr> {foreach from=$shop item=i} <tr align="center"> <td class='xh'>{$i["id"]}</td> <td>{$i["name"]}</td> <td>{$i["varietyid"]}</td> <td>{$i["classifyid"]}</td> <td>{$i["list_pic"]}</td> <td>{$i["introduction"]}</td> <td>{$i["show_pic"]}</td> <td>{$i["product_introduction"]}</td> <td>{$i["company"]}</td> <td>{$i["business_start"]}</td> <td>{$i["business_end"]}</td> <td>{$i["address"]}</td> <td>{$i["rest_flag"]}</td> <td>{$i["web"]}</td> <td>{$i["del_flag"]}</td> <td>修改 删除 </td> <td>上移</td> <td>下移</td> <td>置顶</td> </tr> {/foreach} </table>
[/code]
错误代码:
Fatal error: Uncaught –> Smarty Compiler: Syntax error in template “C:\wamp\www\xcx\user\templates\shop.tpl” on line 154 “$.post(“yidong.php”,{xh :r});” – Unexpected ” :”, expected one of: “}” <– thrown in C:\wamp\www\xcx\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 154
回复讨论(解决方案)
smarty 模版中有错误,导致模版编译失败。
检查下模版中代码内容。
smarty 模版中有错误,导致模版编译失败。
检查下模版中代码内容。
发的代码就是模板里的 $.post(“yidong.php”,{xh :r});这句 有错误 $.post(“yidong.php”);这样输出就没有错误 但是达不到效果啊
js 花括号与 smarty 定界符冲突问题,可以这样保护一下js代码不被编译。
{literal}
<script language=javascript>
……..
</script>
{/literal}
其实也不必,加个空格就可以
$.post(“yidong.php”,{ xh :r });
或者换个定界符
使用 {literal} 标记有个坏处:js 代码终究不能有模板变量了
比较好是修改smarty的定界符。
其实也不必,加个空格就可以
$.post(“yidong.php”,{ xh :r });
或者换个定界符
使用 {literal} 标记有个坏处:js 代码终究不能有模板变量了
加空格不好用啊, 现在上下移动没有动作了 也没办法获取数组
比较好是修改smarty的定界符。
怎么改啊 换掉大括号么 ?
用{literal}
搞gaodaima代码
<script language=”javascript”>
……..
</script>
{/literal}
这样,你试试可以不?