0

I am parsing a value from a HTML element in cakephp and is being sent via Ajax to the following url;

 getquestion.json?data[Job][qs1]=2

Now I am trying to access data[Job][qs1] in the controller but can't figure it out.

The returned array is;

Array ( [data] => Array ( [Job] => Array ( [qs1] => 2 ) ) ) 

$_GET['data[Job][qs1]']; is not working which is rather odd.

1
  • please always mention your exact CakePHP version! Commented Aug 12, 2014 at 14:59

1 Answer 1

2

You are nesting data in your $_GET parameters. To access nested array, just try with:

$_GET['data']['Job']['qs1']
Sign up to request clarification or add additional context in comments.

1 Comment

In CakePHP one should use CakeRequest to retrieve the data. $this->request->query('data.Job.qs1') or $this->request->query['data']['Job']['qs1'] (Cake 2.x), or $this->params['url']['data']['Job']['qs1'] (CakePHP 1.3).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.