I'm trying to append the content from one of the view file (page.ctp) into another view file (index.ctp). So basically what I'm trying to do is:
content from page.ctp ----> index.ctp

I managed to get the content of page.ctp using below method.

$.get('http://localhost/pages/10', function(data) {

But based on console.log(data) instead of getting the content of page.ctp, I got the whole page.ctp + default layout. What I want now is to get the content of page.ctp only excluding other default layout file.

Hope someone can help me with this. Thank you.

In the above code, you are typically asking JQuery to get the whole page.. And it does bring in the whole page. What you can do is.. implement a page where-in it only brings out the content and not the layout part. And then you could query that with $.get() so that you can directly add it to the DOM. with $("#insert_here").html(data);

This would reduce a lot of effort.

The other thing that you could try is to take the whole data .. Build a DOM object and traverse to the content. And then append the data only to the page.. This would be completely on the client side with JS..

I am just guessing this out of the blue.. However there might be other effective solutions :)

Thank you for replied. I already solved this yesterday. What I did is I put below code inside the function that were called by the link. I don't know whether this is the correct solution but so far it works. :)