你的问题很混乱,但我会尽我所能提供帮助。我假设你想通过AJAX检索这些信息。我还假设您的CakePHP控制器吐出以下调用时(你可以去了解一下:http://yoursite/Forms/views):
This is some random string
为了用这个作为我认为,你将需要做到这一点:
<script language="javascript">
$(function() {
$(".select"+increment).change(function() {
$.get('/Forms/views',{},function(data) {
if(data == 'This is some random string') {
// I have no idea where you are getting the
// 'stringinc' and 'labelname' variables from.
$("<label id=labelstr"+stringinc+" >"+labelname+"</label>").appendTo(".menu li");
$("<input id=inputstr"+stringinc+" type= 'text' ></input>").appendTo(".menu li");
}
});
});
});
</script>
现在,如果你正在试图做到这一点奥利弗是在暗示(除了刚刚在CakePHP中)的方式,你需要做的是:
<script language="javascript">
$(function() {
$(".select"+increment).change(function() {
// I'm not familiar with Cake, you might need to use
// some sort of template syntax. Either way, whatever
// method you need to use to get the value into you view
// let's just assume its called '$value_from_controller'.
var data = <?= $value_from_controller; ?>;
if(data == 'This is some random string') {
// I have no idea where you are getting the
// 'stringinc' and 'labelname' variables from.
$("<label id=labelstr"+stringinc+" >"+labelname+"</label>").appendTo(".menu li");
$("<input id=inputstr"+stringinc+" type= 'text' ></input>").appendTo(".menu li");
}
});
});
</script>
我希望能以某种方式提供帮助。
你必须更具体 - 控制器是什么类型,它是否在服务器上?你想要完成什么?你需要更好地介绍你的问题,因为很难辨别你想要达到的目标。 – 2009-05-20 12:17:34
不知道这个问题是关于什么。 jQuery没有任何称为“控制器”的东西 – 2009-05-20 12:41:13