Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6541231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:04:46+00:00 2026-05-25T11:04:46+00:00

Well, I am new to CakePHP. So a painful day to debug this. Here

  • 0

Well, I am new to CakePHP. So a painful day to debug this. Here are my code:

templates_controller.php

    function reajax($id = NULL) {       
        $this->layout = false;
        $this->Template->id = $id;
        $template = $this->Template->read();
        $this->set('result', $template['Template']['content']);
    }

reajax.ctp

echo $result;

js file

$(document).ready(function() {
       $(".abcd").click(function(event){
           event.preventDefault();
           var id = this.id;
           $.ajax({
               type:"GET",
               url:"/templates/reajax/" + id,
               success : function(data) {
                   alert('success');
                   $("textarea").text(data);
               },
               error : function() {
                   alert(id);
               },
           })
       });
})

The click file

    <ul class="content-box-tabs">
      <?php echo $html->link($html->image('thumbnails/'.$template['Template']['thumbnail'], array('alt' => 'test', 'height' => '120', 'width' => '110')), array('controller' => 'templates', 'action' => 'reajax'), array('class' => 'abcd', 'id' => $template['Template']['id'], 'escape' => false))?> 
    </ul>

Every time I get a error result, and I have no idea what’s wrong with my code. Can anyone help me? Thanks in advance.

Everything is going well when I edit the JS file below. I don’t know if this is a bug of CakePHP or if there is something else wrong with my code. I need a spider man!

$(document).ready(function() {
           $(".abcd").click(function(event){
               event.preventDefault();
               var id = this.id;
               $.ajax({
                   type:"GET",
                   url:"/cakephp/templates/reajax/" + id,
                       //url: "/templates/reajax/" + id,
                   success : function(data) {
                       alert('success');
                       $("textarea").text(data);
                   },
                   error : function() {
                       alert(id);
                   },
               })
           });
    })
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:04:47+00:00Added an answer on May 25, 2026 at 11:04 am

    The reason you get an error always is because you are never returning a response from the action you have to do an echo of a json for instance, you are simply setting the data and that’s it.

    You should also have some kind of validation in your controller method, what happens if the template with the provided ID does not exist? You will get an error and are not handling it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to cakePHP and fairly new to PHP as well, I have
Well, I encountered this new term in programming. What is it? How does it
I need to define new UI Elements as well as data binding in code
I am new to CodeIgniter bu I know CakePHP pretty well. If I rewrite
I'm new to CI but I know CakePHP pretty well. I've searched the documentation
Well im new to javascript but why does this not work, all i want
I am starting out on a new project (well, restarting an existing one), and
Well, I'm completely new to JavaScript. Can you please tell me what type of
Starting a new rails project and we have a well-thought-out color palette, and want
I'm new to NHibernate and FNH as well. I'm familiar with ORM's and decided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.