Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery在smarty代码上抛出未捕获错误_Javascript_Jquery_Smarty_Prestashop_Prestashop 1.5 - Fatal编程技术网

Javascript jQuery在smarty代码上抛出未捕获错误

Javascript jQuery在smarty代码上抛出未捕获错误,javascript,jquery,smarty,prestashop,prestashop-1.5,Javascript,Jquery,Smarty,Prestashop,Prestashop 1.5,我有以下错误消息 Uncaught Error: Syntax error, unrecognized expression: [value={if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{/if}] 源于此代码的: $('.id_state option[value={if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}]').pr

我有以下错误消息

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

$('.id_state option[value={if isset($smarty.post.id_state) {$smarty.post.id_state|intval}{/if}]').prop('selected', true);
我不知道它为什么会抛出这样的错误,因为它后面的代码(实际上是下一行)工作起来很有魅力

以下代码正常工作

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

isset()之后缺少一个}结束符。

您的代码:

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

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

你错过了
}
之后的
($smarty.post.id\u state)
谢谢你注意到这一点,我想我现在需要更多的咖啡因