[英]Trouble writing php variables into javascript
'success'=>'js: function(data) {
$("#addToListDialog$model->product_id").dialog().dialog("close");}'
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. 我正在尝试编写上面的javascript,但无法获得正确的花括号组合单/双引号以解析PHP变量。 How should I be writing this?
我该怎么写这个?
A cleaner way: 更清洁的方式:
'success'=>'js: function(data) {
$("#addToListDialog'.$model->product_id.'").dialog().dialog("close");}'
Your PHP string must be in double quotations. 您的PHP字符串必须是双引号。
This should do the trick: 这应该做的伎俩:
'success'=>"js: function(data) {
$(\"#addToListDialog{$model->product_id}\").dialog().dialog(\"close\");}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.