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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:24:35+00:00 2026-06-13T04:24:35+00:00

$.post(http://localhost/academico/materias/getid, ui.item.value, function(data){ console.log(data); }, json); In my controller the $data variable is always

  • 0
$.post("http://localhost/academico/materias/getid",
       ui.item.value,
       function(data){
           console.log(data);
       }, "json");

In my controller the $data variable is always null:

// $data is always null. How come?
public function getid($data = null) {
    debug($data);
    // Como vamos a retornar solamente datos, no necesitamos el layout.
    $this->layout = null;

    $this->set('data', $data);
    $this->render('/Elements/ajaxreturn');
}

How can I get the value POST’d to be bound to something I can use in the Controller 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-06-13T04:24:38+00:00Added an answer on June 13, 2026 at 4:24 am

    You don’t need to define the $data variable as a parameter to the function, that expects it to be present in the URL. POST data is automatically populated in the Request object.

    http://book.cakephp.org/2.0/en/controllers/request-response.html#accessing-post-data

    “All POST data can be accessed using CakeRequest::$data. Any form data that contains a data prefix, will have that data prefix removed.”

    $this->request->data
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What's wrong with this code? I'm not able to validate 'data': $.post('http://localhost/do.php', function(data) {
My flash code: var request=new URLRequest('http://localhost/test.php'); request.method = URLRequestMethod.POST; var data = new URLVariables();
I am querying a php script using js with following func call: $.post(http://localhost/abc/create.php,{ name:data
I am learning to implement restful webservices with Jersey. I always get POST http://localhost:8080/rest/welcome/post
I'm trying to achieve URLs like this in Rails: http://localhost/posts/1234/post-slug-name with both ID and
I need to call an API with POST arguments, for example: URL = http://localhost/myAPI/
I'm making the following request through command-line cURL: curl -X POST http://localhost:8000/api/places/ -vvvv -d
I am getting following error ... POST http://localhost:8080/mytest/admin/user/delete?_dc=1329102157683 415 (Unsupported Media Type) I get
I am submitting a post request with data type json. I am able to
I'm trying the following: $(#button_feedback).click(function () { $.ajax({ type: POST, contentType: application/json; charset=utf-8, url:

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.