$.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]
編號 |
名 稱 |
種 類 |
類 別 |
圖 片 |
簡 介 |
圖 示 |
介 紹 |
公 司 |
開 始 |
結 束 |
地 址 |
休 息 |
網 址 |
停 止 |
操 作 |
排 序 |
|
|
{foreach from=$shop item=i}
| {$i["id"]} |
{$i["name"]} |
{$i["varietyid"]} |
{$i["classifyid"]} |
{$i["list_pic"]} |
{$i["introduction"]} |
{$i["show_pic"]} |
{$i["product_introduction"]} |
{$i["company"]} |
{$i["business_start"]} |
{$i["business_end"]} |
{$i["address"]} |
{$i["rest_flag"]} |
{$i["web"]} |
{$i["del_flag"]} |
修改 刪除 |
上移 |
下移 |
置頂 |
{/foreach}
[/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}
{/literal}
其實也不必,加個空格就可以
$.post("yidong.php",{ xh :r });
或者換個定界符
使用 {literal} 標記有個壞處:js 代碼終究不能有模板變數了
比較好是修改smarty的定界符。
其實也不必,加個空格就可以
$.post("yidong.php",{ xh :r });
或者換個定界符
使用 {literal} 標記有個壞處:js 代碼終究不能有模板變數了
加空格不好用啊, 現在上下移動沒有動作了 也沒辦法擷取數組
比較好是修改smarty的定界符。
怎麼改啊 換掉大括弧麼 ?
用{literal}
{/literal}
這樣,你試試可以不?