麻烦写PHP变量转换为JavaScript转换为、变量、麻烦、JavaScript

2023-09-10 18:11:32 作者:已没权利表达

 'success'=>'js: function(data) {
        $("#addToListDialog$model->product_id").dialog().dialog("close");}'

我想上面写的一块的JavaScript,但不能为了解决PHP变量大括号单/双引号的正确组合。我应该怎么写呢?

I'm trying to write the above piece of javascript, but can't get the right combination of curly brackets a single/double quotes in order to resolve the PHP variable. How should I be writing this?

推荐答案

一个更清洁的方式:

'success'=>'js: function(data) {
        $("#addToListDialog'.$model->product_id.'").dialog().dialog("close");}'