Home > Backend Development > PHP Tutorial > $.post 异常咋回事

$.post 异常咋回事

WBOY
Release: 2016-06-13 12:25:31
Original
1693 people have browsed it

$.post 错误怎么回事?
$.post 错误怎么回事?

$(function(){<br />  $('#bn').click(function() {<br />    var r = [];<br />    $('.xh').each(function(i, t) {<br />      r.push($(this).html());<br />    });<br />    alert(r);<br />	$.post("yidong.php",{xh :r});<br />  });<br />});[code=php]<table class="result-tab" width="100%" cellspacing="0" ><br />                <tr align="center"><br />                  <td align="center"><h2><a href="javascript://" onclick="sendRequest('pid');">编号</a></h2></td><br />                  <td><h2><a href="javascript://" onclick="sendRequest('pname');">名 称</a></h2></td><br />                  <td><h2><a href="javascript://" onclick="sendRequest('pID');">种 类</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">类 别</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">图 片</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">简 介</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">图 示</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">介 绍</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">公 司</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">开 始</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">结 束</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">地 址</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">休 息</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">网 址</a></h2></td><br />				  <td><h2><a href="javascript://" onclick="sendRequest('pID');">停 止</a></h2></td><br />				  <td><h2>操 作</h2></td><br />				  <td><h2>排 序</h2></td><td><h2><td><input type=button value=确认 id=bn></td></h2></td>				  <br />                </tr><br />                {foreach from=$shop item=i}<br />                    <tr align="center"><br />                      <td class='xh'>{$i["id"]}</td><br />                      <td>{$i["name"]}</td><br />					  <td>{$i["varietyid"]}</td><br />					  <td>{$i["classifyid"]}</td><br />					  <td>{$i["list_pic"]}</td><br />					  <td>{$i["introduction"]}</td><br />					  <td>{$i["show_pic"]}</td><br />					  <td>{$i["product_introduction"]}</td><br />					  <td>{$i["company"]}</td><br />					  <td>{$i["business_start"]}</td><br />					  <td>{$i["business_end"]}</td><br />					  <td>{$i["address"]}</td><br />					  <td>{$i["rest_flag"]}</td><br />					  <td>{$i["web"]}</td><br />					  <td>{$i["del_flag"]}</td><br />                      <td><a href="user_shop.php?id={$i["id"]}">修改</a> <a href="delete_shop.php?id={$i["id"]}">删除</a> </td><br />                    <br />					<td><a href="#" class="up">上移</a></td><br />                    <td><a href="#" class="down">下移</a></td><br />					<td><a href="#" class="top">置顶</a></td><br />					</tr><br />                {/foreach}<br />              </table>
Copy after login
[/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: "}" 
------解决思路----------------------
js 花括号与 smarty 定界符冲突问题,可以这样保护一下js代码不被编译。
{literal}
<script><br /> ........<br /></script>
{/literal}
------解决思路----------------------
其实也不必,加个空格就可以
$.post("yidong.php",{ xh :r });

或者换个定界符

使用 {literal} 标记有个坏处:js 代码终究不能有模板变量了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template