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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:25:05+00:00 2026-06-05T12:25:05+00:00

I have a controller where i have a method called index. In this method

  • 0

I have a controller where i have a method called index.
In this method i am retrieveing data from database and using a paging library setting variables for view for paging. When i add a new record i am hitting another function using ajax. There after insertion i call

$this->index();

Now in index i am checking a condition

if($this->input->is_ajax_request()){
    //dont load header and footer
}

but the problem is that when i come to index from my save function it looses the ajax request and my condition in index function in not checked and header and footer is always loaded. I want the ajax request still be available even if i jump from one method of codeigniter to another? Any suggestion? Or alter native.
Because i dont want to create another function where create the paging again with header and footer ommited.

  • 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-05T12:25:07+00:00Added an answer on June 5, 2026 at 12:25 pm

    Something that might be useful is CodeIgniter’s session class which has a flashdata method. Flashdata is a bit of session data that is only stored for the next server request, then it is deleted.

    In your save function, you could have this at the end:

    $this->session->set_flashdata('ajax', true);
    

    and as part of the condition in your index function, you could have:

    if($this->input->is_ajax_request() || $this->session->flashdata('item')){
        //dont load header and footer
    }
    

    This would then check that the request was actually an ajax request OR that a session variable has been temporarily set to tell CodeIgniter that it should be treated like an ajax request.

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

Sidebar

Related Questions

I have this controller method: [GET(/whatever/list)] public ActionResult Index(string sortby, string order) I'm trying
I have a controller which has a method called history class UsersController < ApplicationController
I have a controller method that is a little something like this: def suggestions
I have a controller that is being called twice from an ActionLink call. My
I have a controller called MetricsController with a single action method: public class MetricsController
So I have this controller called Cars, and it has: namespace MySite.Controllers { public
I have a method in a codeigniter controller which is sometimes called through the
I am using ASP.NET MVC 3. I have an action method called New. When
I'm using Ruby version 1.8.7 Rails version 3.0.3 I have a method called alive
I have a controller called HomeController with the actions Index(), MethodOne() and MethodTwo(). Each

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.