$.post 錯誤怎麼回事?

來源:互聯網
上載者:User
$.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} 
    {/foreach} 
  

編號

名 稱

種 類

類 別

圖 片

簡 介

圖 示

介 紹

公 司

開 始

結 束

地 址

休 息

網 址

停 止

操 作

排 序

{$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"]} 修改 刪除 上移 下移 置頂
[/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}
這樣,你試試可以不?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.