2009-06-10 92 views
0

我试图检索一个特定变量的值并提醒它。 也就是说,我想在该变量中获得值“{”attributes“:[{”type“:”Text“,”labels“:”Untitled1“}]} ”。在ajax中使用success:function(msg),我提醒了这个值。如何防止在CakePHP中呈现布局的Ajax警报?

而不是所需的值:{“attributes”:[{“type”:“Text”,“labels”:“Untitled1”}]} 我得到下面给出的文本。问题是什么?

1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title> 
      CakePHP: the rapid development php framework:  Forms 
     </title> 
    <link href="/cake_1_2/favicon.ico" type="image/x-icon" rel="icon" /> 
    <link href="/cake_1_2/favicon.ico" type="image/x-icon" rel="shortcut icon" /> 
    <link rel="stylesheet" type="text/css" href="/cake_1_2/css/cake.generic.css" /> 
    </head> 

    <body> 
     <div id="container"> 

     <div id="header"> 
      <h1> 
      <a href="http://cakephp.org">CakePHP: The rapid development php framework</a> 
      </h1> 
     </div> 

     <div id="content"> 

        {"attributes":[{"type":"Text","labels":"Untitled1"}]} 

     </div> 

     <div id="footer"> 
      <a href="http://www.cakephp.org/" target="_blank"> 
      <img src="/cake_1_2/img/cake.power.gif" alt="CakePHP: The rapid development php framework" border="0" /> 
      </a> 
    </div> 
    </div> 
</body> 

回答

3

的问题是,你仍然使用的默认布局。尝试切换到另一个发货的布局以获取Ajax响应:

// In your controller 
$this->layout = 'ajax'; 
+0

谢谢。有效.. – Angeline 2009-06-10 06:26:06