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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:52:20+00:00 2026-05-13T09:52:20+00:00

I’m a heavy Codeignitor user and currently I have to build a page with

  • 0

I’m a heavy Codeignitor user and currently I have to build a page with extensive AJAX bits and pieces. I have been using JQuery all along the website and it’s AJAX handling was perfect up until now. There is something that just doesn’t feel right when i use a MVC with JQuery.
For example:
in Jquery I setup the callback URL easily that point to the controller, the controler then calls a view page and the AJAX is displayed but this view page is very small PHP code.
So now I have about 40 ajax function to do in my page, would that mean I would have to make 40 views?? that doesn’t seem right to me.
Is there any better way to handle/manage the views created for the AJAX in MVC Frameworks

Thank you.

  • 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-13T09:52:20+00:00Added an answer on May 13, 2026 at 9:52 am

    You could create one view, e.g. ajax.php and set the content accordingly in the methods of the controllers. All methods can use the same view.

    The above is only true for similar views, but if the methods are similar as well, then you should think about refactoring your code to using uri parameters, see my answer to a question on how to get parameters from the url.

    But all that depends on the nature of the controllers, their methods and the related views.

    EDIT:

    I do not advise you to use HTML in the controller, but lay out your controller like this:

    Class My_Controller
    {
        // some other methods
        public function edit_via_ajax($type, $value)
        {
            /* do some stuff with $type and $value,
               sanitize user input etc. 
               set $status to TRUE or FALSE */
            $data['type'] = $type;
            $data['value'] = $value;
            if ($status === TRUE)
            {        
                $this->load->view('success.php', $data);
            }
            else
            {        
                $this->load->view('error.php', $data);
            }
        }
    }
    

    Create views like success.php

    <?=$type;?> was successfully set to <?=$value;?>
    

    And call it via $.get('/index.php/my_controller/edit_via_ajax/name/John_Doe'); in jquery to edit the name. In that way, lots of similar AJAX requests can share the same method and methods can share views.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has

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.