0

I am using CakePHP 2.3.6. In one of my projects, I want to use Ajax for searching data. My plan is, user will input parameters/fields to search specific data. After they input data, an Ajax request will be sent to the controller and the controller will return the result data and the result data will be shown in a specific div.

So, first I tried to return the result in normal php array and show that array in a table. But, it didn't work. Then I got a suggestion to use JSON as the return data type. Now I am trying to use it.

But, I don't know yet how to show JSON data/array in a table. So, can you please give me an example of how to do it ?

Thanks

BMN
  • 8,253
  • 14
  • 48
  • 80
Subhasish Saha
  • 13
  • 2
  • 11

1 Answers1

0

Well you will need to do few steps.

  • Create a empty layout that will only print the json.
  • Concatinate the data into a variable and then at the end of the concatication. Use json_encode
  • And echo the JSON string.
  • Then you can simply parse the value and show the results on the AJax requesting page.
Kuldeep Singh
  • 451
  • 2
  • 13