$.post 错误怎么回事?
$.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 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pid-编号-a"><a href="javascript://" onclick="sendRequest('pid');">编号</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pname-名-nbsp-称-a"><a href="javascript://" onclick="sendRequest('pname');">名 称</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-种-nbsp-类-a"><a href="javascript://" onclick="sendRequest('pID');">种 类</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-类-nbsp-别-a"><a href="javascript://" onclick="sendRequest('pID');">类 别</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-图-nbsp-片-a"><a href="javascript://" onclick="sendRequest('pID');">图 片</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-简-nbsp-介-a"><a href="javascript://" onclick="sendRequest('pID');">简 介</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-图-nbsp-示-a"><a href="javascript://" onclick="sendRequest('pID');">图 示</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-介-nbsp-绍-a"><a href="javascript://" onclick="sendRequest('pID');">介 绍</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-公-nbsp-司-a"><a href="javascript://" onclick="sendRequest('pID');">公 司</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-开-nbsp-始-a"><a href="javascript://" onclick="sendRequest('pID');">开 始</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-结-nbsp-束-a"><a href="javascript://" onclick="sendRequest('pID');">结 束</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-地-nbsp-址-a"><a href="javascript://" onclick="sendRequest('pID');">地 址</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-休-nbsp-息-a"><a href="javascript://" onclick="sendRequest('pID');">休 息</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-网-nbsp-址-a"><a href="javascript://" onclick="sendRequest('pID');">网 址</a></h2></td> <td><h2 id="a-nbsp-href-javascript-nbsp-onclick-sendRequest-pID-停-nbsp-止-a"><a href="javascript://" onclick="sendRequest('pID');">停 止</a></h2></td> <td><h2 id="操-nbsp-作">操 作</h2></td> <td><h2 id="排-nbsp-序">排 序</h2></td><td><h2><td><input type=button value=确认 id=bn></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><a href="user_shop.php?id={$i["id"]}">修改</a> <a href="delete_shop.php?id={$i["id"]}">删除</a> </td> <td><a href="#" class="up">上移</a></td> <td><a href="#" class="down">下移</a></td> <td><a href="#" class="top">置顶</a></td> </tr> {/foreach} </table>
错误代码:
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: "}"
回复讨论(解决方案)
smarty 模版中有错误,导致模版编译失败。
检查下模版中代码内容。
smarty 模版中有错误,导致模版编译失败。
检查下模版中代码内容。
发的代码就是模板里的 $.post("yidong.php",{xh :r});这句 有错误 $.post("yidong.php");这样输出就没有错误 但是达不到效果啊
js 花括号与 smarty 定界符冲突问题,可以这样保护一下js代码不被编译。
{literal}
<script> <br /> ........ <br /></script>
{/literal}
其实也不必,加个空格就可以
$.post("yidong.php",{ xh :r });
或者换个定界符
使用 {literal} 标记有个坏处:js 代码终究不能有模板变量了
比较好是修改smarty的定界符。
其实也不必,加个空格就可以
$.post("yidong.php",{ xh :r });
或者换个定界符
使用 {literal} 标记有个坏处:js 代码终究不能有模板变量了
加空格不好用啊, 现在上下移动没有动作了 也没办法获取数组
比较好是修改smarty的定界符。
怎么改啊 换掉大括号么 ?
用{literal}
<script> <br /> ........ <br /></script>
{/literal}
这样,你试试可以不?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
