简体   繁体   English

jQuery在Smarty代码上引发未捕获的错误

[英]jQuery throws uncaught error on smarty code

I have the following error message 我有以下错误信息

Uncaught Error: Syntax error, unrecognized expression: [value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}]

Which originating from this code: 哪个源于此代码:

$('.id_state option[value={if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}]').prop('selected', true);

I am not sure why it throws such error, since the code following it (literallly the next line) works like a charm 我不确定为什么会引发这样的错误,因为它后面的代码(基本上是下一行)像一个超级字符一样起作用

The following code works normally 以下代码正常工作

$('.id_state_invoice option[value={if isset($smarty.post.id_state_invoice)}{$smarty.post.id_state_invoice|intval}{/if}]').prop('selected', true);

isset()之后,您缺少结束符}。

your code: 您的代码:

{if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}

needs to be: 需要是:

{if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM