Return JSON Response in CodeIgniter controller

Codeigniter php Programming Technology

Today, We want to share with you Return JSON Response in CodeIgniter controller.In this post we will show you send json response codeigniter example, hear for codeigniter json encode array we will give you demo and example for implement.In this post, we will learn about codeigniter json response with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Snippet Contents

Return JSON Response in CodeIgniter controller

There are the Following The simple About Return JSON Response in CodeIgniter controller Full Information With Example and source code.

As I will cover this Post with live Working example to develop get json response php codeigniter, so the codeigniter return json header for this example is following below.

Json Response

public function returnMyProductJson() { 
  header('Content-Type: application/json');
  $productArray = ['id'=>9898, 'name'=>'Mobile'];
  echo json_encode($success);

Completed Source Code


  // load view

 public function productDetails(){
  // POST data
  $postProductData = $this->input->post();

  //load model

  // get data
  $data = $this->Main_model->getProductDetails($postProductData);

  echo json_encode($data);


Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to send json response from controller in codeigniter ?.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP – Split a String into Array with Delimiter
  2.   Laravel Search Comma Separated values Example
  3.   Remove null from array Jquery Example
  4.   Laravel 6 JQuery Ajax Post Request Example
  5.   Disable browser back button using jquery
  6.   how to get last inserted id in laravel 6
  7.   Angular 9/8 Material Radio Button Examples
  8.   laravel Check Request is Ajax Example
  9.   Import and Export CSV File using Laravel 6 and MySQL
  10.   Angularjs Progress Bar Demo with Example

Leave a Reply

Your email address will not be published. Required fields are marked *