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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:21:39+00:00 2026-05-26T01:21:39+00:00

I am performing the jquery POST correctly, however I would like to call another

  • 0

I am performing the jquery POST correctly, however I would like to call another PHP function inside the controller. EDIT The code below works fine….I’m just an idiot. Someone close this please.

Here is the setup:

class controller extends CI_Controller {

  function con1() {
  //retrieve post variable
  $this->con2()
  }

  function con2() {
  //do something
  $this->my_model->get_results() //fails
  }

}

Jquery POSTS to con1, however it will fail when i do $this->con2(). Is there anyway I can get this to work? Also, is it possible to call a model once jquery posts the data?

Thanks

  • 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-26T01:21:39+00:00Added an answer on May 26, 2026 at 1:21 am

    It’s not really clear what you aren’t able to do, but why are you juggling with controller’s methods, when model are done just for that?
    The purpose of a Model is being something re-usable, so why don’t you call it right in con1() method?

    class Controller extends CI_Controller {
    
      function con1() {
      $this->load->model('my_model');
      //retrieve post variable
      echo $this->my_model->get_results(); 
      }
    }
    

    Also, post variable are available to Models also, if you want to grab their values there.
    If you expand your answer with further details I’ll edit and update my question, so far it’s just a bit of a guessing on what’s wrong. The code I showed should work, provided the get_result() method actually returns something (which you need to echo out).

    If by “how do I call a function within a model” means how you call a model’s method inside another model’s method, well, it works like any php class method’s call, $this->other_method();

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

Sidebar

Related Questions

When performing many inserts into a database I would usually have code like this:
The problem is about communicating an object between PHP and JQuery. Performing $.post in
What is below jQuery code performing ? inputMapVar.each(function(index){ $(this).prev().removeClass(MISSING); });
I am performing a jQuery .ajax() call that returns a List<string> of IP addresses
I'm trying to get better at using Jquery and therefore would like feedback on
I am performing a simple AJAX() request using Jquery (Google hosted 1.7.1 jquery.min.js code)
Here is my code in my jquery/javascript that is performing the ajax request... else
I'm performing a very simple onmouseover fadeTo like this: $(document).ready(function() { $('img#logo-link, a.advert').hover(function() {
I have got below JQuery where I am performing the .load function. $(.load-fragment).each(function() {
I am performing a standard update in NHibernate to a single property. However on

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.