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

  • Home
  • SEARCH
  • 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 8610893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:14:09+00:00 2026-06-12T04:14:09+00:00

I have a function in my controller: function getAllExpense() { $date=$this->frenchToEnglish_date($this->input->post(‘date’)); $id_user=$this->session->userdata(‘id_user’); $where=array(‘date’=>$date, ‘id_user’=>$id_user);

  • 0

I have a function in my controller:

function getAllExpense()
    { $date=$this->frenchToEnglish_date($this->input->post('date'));
      $id_user=$this->session->userdata('id_user');
      $where=array('date'=>$date, 'id_user'=>$id_user);
      $allExpenses=$this->expenses_model->get_all('depenses',$where);
      return json_encode($allExpenses);

    }

In the view, I need to do an ajax_call to getAllExpense, but I need also to retrieve the result returned by getAllExpense in case of success(and I can’t do this). Here is my view

function searchExpense()
    {
      var date= $('#dateSearch').val();
      $.ajax({
                            type:'POST',
                            url : '<?php echo site_url()."/public/expenses/getAllExpense/"; ?>',
                            data :'date='+date,

                            success:function(data)
                            {          $('#searchExpense').toggle();


                            }

                    });     
    }

and finally the form :

<div id="searchExpense" class="toogle_form" style="display:none">
           <label><strong>Vos depenses :</strong></label>
           <?php
              if (isset($allExpenses) && ! empty($allExpenses))
                                            {
                          foreach ($allExpenses as $expense)
                                    {
                                      echo $expense['id_depense'] ;
                                      echo ' ';
                                      echo $expense['commentaire'];
                                      echo '</br>';
                                        }
                              }
                              else
                              {
                                echo 'Vous n\'avez pas eu de depenses pour cette date';
                              }
            ?>
       </div>

This does not show anything on the browser.
I can’t use the method of sending data by loading the view in getAllExpense because I already load it in the function index.
Could anyone help me please?

  • 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-12T04:14:10+00:00Added an answer on June 12, 2026 at 4:14 am

    In your controller function getAllExpense, try echoing your json data with a header rather than using return:

    Change this:

    return json_encode($allExpenses);
    

    to:

    $this->output->set_header('Content-Type: application/json; charset=utf-8');
    echo json_encode($allExpenses);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller named categories in which I have function description($id=null) { $this->load->helper(array('form',
I have this function on my controller (Im using CodeIgniter) that reads the database,
I have a private function like this in my controller. private UserDetails GetUserDetails(int userid)
I have this code in my controller (admin): function save(){ $model = $this->getModel('mymodel'); if
i have this controller function: Public Function Index(ByVal id As System.Nullable(Of Integer)) As ActionResult
I have this code: // controller function contact($token) { $this->layout = 'ajax'; } //
I have this function in my controller: def showRecipeIngredients ingredients = RecipeIngredient.where( recipe_id =
Let's say I have a controller function with these lines: $this->load->view('stdHeader_view'); echo <div class='main'>;
I have this function in my controller. If I add an image, it works
I have this controller function that returns cpu stats: public ActionResult GetStats() { Random

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.