$.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]编号 | 名 称 | 种 类 | 类 别 | 图 片 | 简 介 | 图 示 | 介 绍 | 公 司 | 开 始 | 结 束 | 地 址 | 休 息 | 网 址 | 停 止 | 操 作 | 排 序 | ||
| {$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"]} | 修改 删除 | 上移 | 下移 | 置顶 |
错误代码:
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
------解决思路----------------------
js 花括号与 smarty 定界符冲突问题,可以这样保护一下js代码不被编译。
{literal}
{/literal}
------解决思路----------------------
其实也不必,加个空格就可以
$.post("yidong.php",{ xh :r });
或者换个定界符
使用 {literal} 标记有个坏处:js 代码终究不能有模板变量了