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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:53:12+00:00 2026-05-24T05:53:12+00:00

This issue is very likely codeigniter specific. I have a controller called redirect.php that

  • 0

This issue is very likely codeigniter specific.

I have a controller called redirect.php that redirects from and to views. This controller for the most part has one public _remap function that does all the redirecting with a case statement. Everything has been working great until I sent a $.POST from a view back to the controller. I want it to hit the _remap and look for the fact that the request is coming from AJAX then do it’s case.

I have a IS_AJAX constant I’m checking against.

define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

but whenever I hit the page it’s always remapping to the default and sending my request to that page where it’s basically returning me that pages data back when I’m echoing and alerting the data to and fro.

Any insights?

for reference,

redirect.php (there is more code to define variables and 2 more cases but it’s not hitting those, it’s hitting ‘index’ / default)

 public function _remap($method)
        {   

    switch ($method) {
        case $method == 'index':
        $this->load->view('main');
            break;
        case $method == 'IS_AJAX':
        var_dump($_POST);
            break;
        default:
        $this->load->view('main');
            }
        }

tweetview.php (view loaded by redirect controller in another case within redirect.php, json_tweets send is a JSON variable)

//jquery

$.post("http://localhost/2fb/index.php/redirect", {'json_tweets': json_tweets},
   function(data) {
     alert(data);
   });
  • 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-24T05:53:14+00:00Added an answer on May 24, 2026 at 5:53 am
    case $method == 'IS_AJAX':
    

    Your $method is not IS_AJAX with this url:

    http://localhost/2fb/index.php/redirect
    

    This would bring you to the redirect controller without a method (will default to “index”). You literally would need:

    http://localhost/2fb/index.php/redirect/IS_AJAX
    

    …to step into that case. You seem to be confusing your constant IS_AJAX with the method requested, which you seem to be using correctly when checking for index (although this is the same as the default case, so it’s redundant).

    $method, or whatever you name the first parameter in _remap(), will always be the routed controller function that is called.

    EDIT: I failed to mention this earlier, but the switch block evaluates the expression you pass to it, so there is no need to do the comparison manually. Example:

    switch ($method) {
        // case $method === 'index':
        case 'index':
            $this->load->view('main');
        break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that seems like very flaky behavour, is this a problem
I have a weird issue with a php redirect script that does the following:
I'm very surprised this issue hasn't been discussed in-depth: This article tells us how
Now I must be missing something here, as this seems a very basic issue
This issue is driving me mad. I have several tables defined, and CRUD stored
Note: This issue appears to be limited to SQL Server 2005 SP2 I have
I've been stuck on this likely very simple problem, but haven't gotten anywhere with
We have a very lengthy newsletter that has been designed and developed to look
We have a drupal site and we wish to export data from this site
So I have this Access Database Project file that I have been tasked to

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.