• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

$.post 错误怎么回事?

php 搞代码 4年前 (2022-01-23) 14次浏览 已收录 0个评论
文章目录[隐藏]

$.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}

本文来*源gaodai^.ma#com搞#代!码网
搞gaodaima代码

<script language=”javascript”>
……..
</script>
{/literal}
这样,你试试可以不?


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:$.post 错误怎么回事?

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址