Reputation: 67
I'm having a little trouble getting Jquery to play nice with cakephp and I'm not really sure what the problem is.
view file, View/Members/index.ctp
<script>
$(document).ready(function(){
$("#place").click(function(event){
$("#place").load('/member/jax', function(){
alert("load successful");
});
});
});
</script>
<div id="place"></div>
Controller file Controller/MembersController
public function jax() {
echo "<p>TESTTHIS</p>";
$this->layout='ajax';
$this->render('/Elements/test');
}
and for completeness
Test element /View/Elements/test.ctp
<b>test element</b>
When I click on the div I get the "load successful" popup, but I do not get the "
TESTTHIS
that I expect the controller to print out, nor do I get the "test element" from the render.Can anyone tell me where I'm going wrong? Thanks.
Upvotes: 1
Views: 1597
Reputation: 1
If you want to load the complete controller with view then print the URL of your controller and view in .load() through PHP
Upvotes: 0
Reputation: 87073
you can try with following:
$("#place").load('/members/jax',...
Conventionally controller in CakePHP call with plural name. So, I think it should members
not member
.
Upvotes: 1