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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:38:44+00:00 2026-05-14T04:38:44+00:00

I use the following the jquery statements to call my php controller function, it

  • 0

I use the following the jquery statements to call my php controller function, it gets called but my result is not returned to my success function….

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="http://localhost/codeigniter_cup_myth/stylesheets/style.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost/codeigniter_cup_myth/stylesheets/calendar.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost/codeigniter_cup_myth/stylesheets/date_picker.css" />
        <script type="text/javascript" src="http://localhost/codeigniter_cup_myth/javascript/jquery1.4.2.js"></script>
        <script type="text/javascript" src="http://localhost/codeigniter_cup_myth/javascript/jquery.pagination.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                getRecordspage();
            });

            function getRecordspage() {
                $.ajax({
                    type: "POST",
                    url:"http://localhost/codeigniter_cup_myth/index.php/adminController/mainAccount",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    global:false,
                    async: true,
                    dataType: "json",
                    success: function(result) {
                        alert(result);
                    }
                });
            }
        </script>
    </head>
    <body>
        <table  id="chkbox" cellpadding="0" cellspacing="2" width="100%" class="table_Style_Border">
            <tr>
                <td class="grid_header" align="center">S.No</td>
                <td class="grid_header" align="center">Account Name</td>
                <td class="grid_header" align="center">Account Acronym</td>
                <td class="grid_header" align="center">Finance Year Start</td>
                <td class="grid_header" align="center">Finance Year End</td>
                <td class="grid_header" align="center">&nbsp;</td>
            </tr>
            <tr> <td colspan="5"> </td></tr>
        </table>
    </body>
</html>

My controller method,

function mainAccount()
{
    $_SESSION['menu'] = 'finance';
    $data['account'] = $this->adminmodel->getaccountDetails();
    if(empty($data['account']))
    {
        $data['comment'] = 'No record found !';
    }
    $json = json_encode($data);
    return $json;
}

I get the alert(1); in my success function but my alert(result); show null. How do I fix this problem?

This was what I got when I gave print_r($data);:

Array ( [account] => Array ( [0] => Array ( [dAcc_id] => 1 [dAccountName] => Govt. College Of Technology [dAccountAcronym] => GCT [dFromDate] => 2010-04-02 [dToDate] => 2011-05-03 ) [1] => Array ( [dAcc_id] => 3 [dAccountName] => sample4 [dAccountAcronym] => smp_4 [dFromDate] => 2010-03-17 [dToDate] => 2011-03-03 ) [2] => Array ( [dAcc_id] => 4 [dAccountName] => sample3 [dAccountAcronym] => smp_3 [dFromDate] => 2010-03-16 [dToDate] => 2011-03-17 ) [3] => Array ( [dAcc_id] => 5 [dAccountName] => sample5 [dAccountAcronym] => smp_5 [dFromDate] => 2010-03-12 [dToDate] => 2011-03-03 ) [4] => Array ( [dAcc_id] => 6 [dAccountName] => sample2 [dAccountAcronym] => smp2 [dFromDate] => 2010-03-01 [dToDate] => 2011-03-16 ) [5] => Array ( [dAcc_id] => 7 [dAccountName] => sample1 [dAccountAcronym] => smp_1 [dFromDate] => 2010-03-11 [dToDate] => 2011-03-03 ) [6] => Array ( [dAcc_id] => 8 [dAccountName] => ss [dAccountAcronym] => ss [dFromDate] => 2010-04-04 [dToDate] => 2010-04-06 ) ) )

When I did print_r(json_encode($data['account']));, I got this:

[{"dAcc_id":"1","dAccountName":"Govt. College Of Technology","dAccountAcronym":"GCT","dFromDate":"2010-04-02","dToDate":"2011-05-03"},{"dAcc_id":"3","dAccountName":"sample4","dAccountAcronym":"smp_4","dFromDate":"2010-03-17","dToDate":"2011-03-03"},{"dAcc_id":"4","dAccountName":"sample3","dAccountAcronym":"smp_3","dFromDate":"2010-03-16","dToDate":"2011-03-17"},{"dAcc_id":"5","dAccountName":"sample5","dAccountAcronym":"smp_5","dFromDate":"2010-03-12","dToDate":"2011-03-03"},{"dAcc_id":"6","dAccountName":"sample2","dAccountAcronym":"smp2","dFromDate":"2010-03-01","dToDate":"2011-03-16"},{"dAcc_id":"7","dAccountName":"sample1","dAccountAcronym":"smp_1","dFromDate":"2010-03-11","dToDate":"2011-03-03"},{"dAcc_id":"8","dAccountName":"ss","dAccountAcronym":"ss","dFromDate":"2010-04-04","dToDate":"2010-04-06"}]
  • 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-05-14T04:38:45+00:00Added an answer on May 14, 2026 at 4:38 am

    Have you set the content type correct?

    header('Content-Type: application/json');
    

    With CodeIgniter, are you meant to return the JSON object or output it? If there’s no view associated with the method then nothing will be output. Try, just to see if it works:

    $_SESSION['menu'] = 'finance';
    $data['account'] = $this->adminmodel->getaccountDetails();
    if (empty($data['account'])) {
      $data['comment'] = 'No record found !';
    }
    header('Content-Type: application/json');
    echo json_encode($data);
    exit;
    

    Lastly, verify the URL you are going to and see if it returns something.

    Take a look at JSON Helper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 379k
  • Answers 379k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer WPF's animation system has the ability to set sub-properties of… May 14, 2026 at 9:27 pm
  • Editorial Team
    Editorial Team added an answer MemberExpression has a property called Expression, which is the object… May 14, 2026 at 9:27 pm
  • Editorial Team
    Editorial Team added an answer You can use the standard manipulators from <iomanip> but there… May 14, 2026 at 9:27 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.