【发布时间】:2011-11-30 06:45:38
【问题描述】:
我想在触发 select 的事件 onchange 时显示一个测试 div,但结果显示 div 总默认布局。我只希望test.ctp 出现在我的结果 div 中。
这是我的代码,请告诉这里有什么问题。我有一个带有id="ProductCategoryId" 的下拉列表,结果是div,例如:
<div id="result">result html</div>
这是 jQuery 函数:
$("#ProductCategoryId").change(
function() {
var catid = $(this).val();
$.post('product/test', {id: catid},
function(result) {
$('#result').html(result);
});
}
);
在我的product_controller:
function test() {
$this->autorender = false;
$this->layout = 'ajax';
}
在test.ctp 中只写入测试输出。
【问题讨论】:
-
你能告诉我们
test方法的完整代码吗?还是只是你放在这里的东西? -
是的,我要写代码,这只是开始,所以这是基本代码。在 test.ctp 中只是输出在这里写
-
您是否包含了
RequestHandler组件? -
是的,我已经包含了 RequestHandler 组件
-
尝试使用浏览器开发工具(例如 Firebug)测试网络活动,以确认您发出的是 AJAX 请求而不是常规请求
标签: php javascript jquery cakephp cakephp-1.3