小编Chu*_*ess的帖子

在CakePHP视图中呈现jQuery代码时,如何将PHP变量用作<script>标记的值?

我是CakePhp和JQuery的新手.我在使用JQuery中的cakephp代码时遇到错误.

我的代码

   <script type="text/javascript">
     $(document).ready(function(){
     var attributeid;var fieldname;
     $("#"+<?=$r['Attribute']['id'];?>).change(function () {

     fieldname=<?=$r['Attribute']['label'];?>; 
              alert(fieldname);//this show me that undefined 
             attributeid=<?=$r['Attribute']['id'];?>; 
             alert(attributeid);//But this works

    });//attribute change
});//ready function 
Run Code Online (Sandbox Code Playgroud)

如果我回应($r['Attribute']['label'];)这个价值就在我的内心<?php ?>.但不是在我的JQuery中.

注意 :

attributeid=<?=$r['Attribute']['id'];?>; 
alert(attributeid);//But this works  


Error: 
Name is not defined
fieldname=name; 
alert(fieldname);
Run Code Online (Sandbox Code Playgroud)

javascript php jquery cakephp

0
推荐指数
1
解决办法
454
查看次数

为什么我的PHP变量不会出现在CakePHP视图中的HREF中?

在我的CakePHP代码中,我有以下代码.如果我单击图像删除它将移动到href中的链接.在href我不知道如何显示我的PHP值.我尝试过如下,但它不起作用.

   <a href="http://localhost/cake_1.2.1.8004/index.php/forms/delete/"<?php echo $r['Form']['id'];?> >
    <img border="0" alt="Delete" src="/cake_1.2.1.8004/app/webroot/img/delete.png"/>
  </a>
Run Code Online (Sandbox Code Playgroud)

有什么建议?

php cakephp

0
推荐指数
1
解决办法
144
查看次数

cakephp 1.2简单的认证样本

我正在为cakephp 1.2尝试几个身份验证样本,但没有找到任何完美无瑕的代码.你能给我一些代码吗?谢谢

cakephp cakephp-1.2

0
推荐指数
1
解决办法
378
查看次数

CakePHP代码中的注释是否真的使用/必要?

阅读核心并查看几乎所有可用的助手/插件等,我注意到有很多评论.

CakePHP的结构使得确定事物的位置和所做的事情非常简单.是否真的有必要对所有这些代码进行评论?它会使源更混乱还是真的有用?当您查看评论时,您觉得它们有用吗?或者你甚至读过它们?

更新:以下是从CakePHP Core连接管理器获取的注释示例,例如:

/**
 * Loads the DataSource class for the given connection name
 *
 * @param mixed $connName A string name of the connection, as defined in app/config/database.php,
 *                        or an array containing the filename (without extension) and class name of the object,
 *                        to be found in app/models/datasources/ or cake/libs/model/datasources/.
 * @return boolean True on success, null on failure or false if the class is already loaded
 * @access public
 * @static
 */
Run Code Online (Sandbox Code Playgroud)

php cakephp cakephp-1.3 cakephp-1.2

0
推荐指数
1
解决办法
458
查看次数

0
推荐指数
3
解决办法
4777
查看次数