【发布时间】:2012-08-24 05:57:19
【问题描述】:
我需要 CakePHP 1.3 中的一个函数来呈现 jquery 函数使用的值,但它总是在破坏 jquery 的值之前呈现三个新行。设置这些headers 中的任何一个都没有帮助
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
header('Content-Type: text/x-json');
header("X-JSON: ".$content);
echo $content;
jquery 使用:
var content = $.ajax({ url: /link/to/cakephp/function ,async: false }).responseText;
我可以修复那三行或 jquery 函数吗?
【问题讨论】:
-
你的视图中有
$this->layout = 'ajax'吗? -
已经尝试过
$this->autoRender = false;或$this->layout = 'ajax';当autoRender设置为false我只在控制器中显示该值,如果为真我制作一个视图。但无论如何,在呈现视图/值之前我总是得到 3 个空行
标签: php jquery ajax cakephp http-headers