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 6092761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:28:55+00:00 2026-05-23T12:28:55+00:00

I try to send data form ajax to cakephp cotroller function loadtooltip(obj, $user_id) {

  • 0

I try to send data form ajax to cakephp cotroller

function loadtooltip(obj, $user_id) {
 //AJAX
 var req = Inint_AJAX();
 req.onreadystatechange = function () { 
      if (req.readyState==4) {
           if (req.status==200) {
                displaytooltip(obj, req.responseText);
           } 
      } 
 };

 req.open("POST", "http://127.0.0.1/cakeplate/tooltips/tooltip/", true); 
 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 req.send($user_id); 

};

this controller

<?php
Class TooltipsController extends AppController{
var $name = 'Tooltips';
var $uses = array('Reply','User');
var $component = array('RequestHandler','Javascript','Ajax');
var $layout =  'tooltip';


function tooltip($user_id=NULL){

                if(!empty($user_id)){
                    $tooltip = $this->Reply->User->findById($user_id);
                    $this->set('tooltip',$tooltip);
                }

}
}
 ?>

I need somebody to help me to modified code

  • 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-23T12:28:55+00:00Added an answer on May 23, 2026 at 12:28 pm

    the way you’re doing at the moment in the controller, you won’t me able to get the user_id, because it is a var passed through GET method of http.

    This variable would be accessible if you make a GET request for example for this url:
    http://example.com/cakeplate/tooltips/tooltip/1 where 1 would be your $user_id.

    If you send the request as POST, you can access the values in this var $this->data
    This way you will be able to process the request based in the var that you pass to the controller.

    Another problem that you will face that this controller will need to render a view, so i suggest that you take a look at http://book.cakephp.org/view/1238/REST, there you can see how you can create a route that will make the controller parse another view, it a different custom layout, like the json (the one i suggest in this case), and then you can show in this view only the json value.

    Last, but important as well, i would suggest to that you use jQuery to do the javascript part, i think it will be easier, you can check it at http://api.jquery.com/jQuery.get

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

Sidebar

Related Questions

I'm using jQuery's AJAX function to send a message from a contact form -
Im getting a connection refused when I try to send some data to my
I am using Ajax POST method to send data, but i am not able
This is my ajax function: function ajax_call(call_method,data_to_send) { logger(function ajax_call. var data_to_send: ); logger(data_to_send);
$(document).ready(function() { function ajaxselectrss(rssurlvar) { var ajaxRequest; // The variable that makes Ajax possible!
var ajaxRequestqqq; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox,
I try to send POST data to a server using urlfetch in AppEngine. Some
I'm trying to send a lot of data from a form using the $.post
I need a function that click one link, send ajax request to 2 pages
I'm trying to send a form to a PHP using $.ajax in jQuery .

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.