简体   繁体   English

在js变量中插入包含php标签的html代码

[英]Insert a html code containing php tags in a js varibale

I have an HTML logic in main_business.php 我在main_business.php中有HTML逻辑

<div class="large reveal full-size" id="business-modal" data-reveal>
    <?php
        $model = new Form('my-form');
        echo $this->renderPartial('//my/business', array('model'=>$model)); 
    ?>
</div>

and I have another file script.js containging a function open as 我有另一个文件的script.js containging功能open作为

function open() {
  var $model;
} 

Now I want to insert the content of main_business.php into this $modal variable. 现在,我想将main_business.php的内容插入此$modal变量中。

How can I do that? 我怎样才能做到这一点?

function open() {
    var modal = $('#business-modal').html();
    console.log(modal);
}

You need to make new variable in javascript 您需要在javascript中创建新变量

function open() {
    var model= '<?php $model ?>';
}

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

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