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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:55:10+00:00 2026-05-23T09:55:10+00:00

New to HMVC in Codeigniter. Dynamic form allows new segments to be created when

  • 0

New to HMVC in Codeigniter.

Dynamic form allows new “segments” to be created when a user clicks a link.

Currently the segment html & php is in module/view/segment_view.php. The view requires dynamic php variables as well.

How can I “load the view” using jQuery? I understand I can’t directly load a view from jQuery but am lost on how to structure the controller for an AJAX call. Seems this may not be a strength of Codeigniter?

EDIT:
The “segment” is inside a form. The form always has 1 segment. jQuery can add more segments. Each segment requires php arrays for form inputs and validation.

Here is a pared down version of the form_view file

for ($i=1; $i<=$number_of_segments; $i++) {

    $data['location'] = array(
        'name'  =>  "segment[$i][location]",
        'value' =>  set_value("segment[$i][location]"),
        'maxlength' =>  '255',
        'size'  =>  '30'
    );  
 ?>
    <div class="area">
        <div class="row"><h2>Segment <?php echo $i;?></h2></div>

        <?php 
        $this->load->view('module/segment_view', $data);
        ?>

    </div> <!--/div class="area"-->
<?php
}    //end for
?>

OK, so this isn’t really separating application logic from presentation, now is it? Ha ha. So what is the best way to structure this so the code is HMVC and can be accessed from a php controller/view as well as jQuery?

  • 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-23T09:55:11+00:00Added an answer on May 23, 2026 at 9:55 am

    You can’t call view files directly by URL, you need to call a controller method that loads the view.

    If you want to do some “ajax only” stuff, you may use this function:

    if ($this->input->is_ajax_request()) // Do ajax stuff
    

    Examples would be loading view fragments or json. You don’t have to make “ajax only” methods in your controller, you can use this function from within your existing controller methods to do something different if it’s an ajax request.

    Not sure if this resolves anything for you, provide some code and more context of what you’re trying to do and we can give you some clearer advice.

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

Sidebar

Related Questions

New-ish to Rails... I've created a helper to format race names & their dates.
Possible Duplicate: Codeigniter HVMC modular seperation extension URL rewrite / routing I am new
(New to ASP.NET here.) I have a user control which should check for a
New to Flex, what is the nearest equivalent to the following HTML markup in
I am new to Codeigniter and I am thinking about the use of this
I'm currently writing my own PHP framework as a learning exercise using the HMVC
new to ruby, and rails... but not to the amp stack. my preferred method
New formtastic user here. I have a relationship user has_many clients In formtastic ,
I am having trouble getting a working Codeigniter version 2.0.3 with hmvc and tank
New to Git and just started to use Github. Just created my first public

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.