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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:34:44+00:00 2026-06-08T07:34:44+00:00

I am trying to perform a simple JQuery AJAX page load within a CodeIgniter

  • 0

I am trying to perform a simple JQuery AJAX page load within a CodeIgniter 2.x

It also seems to respond differently in different web browsers. NOTE: This is not an incorrect path issue, the pages work and display fine, I have used base_url, realurl, manually typed absolute and manually type relative paths and none give 100% success. At times I think is it the .htaccess file but if it was that it wouldn’t work in all browsers not just all but 1.

This is now working in the following browsers:

  • Chrome – Doesn’t work
  • IE 9 – Works
  • FireFox – Works
  • Safari – Works
  • Opera – Works

I have placed a cleaned CI test site / application online for anyone wishing to help:
Demo (can be tested here too, try points 1,2 & 3 listed on page and watch console outputs):
http://www.allforthecode.co.uk/dev/CodeigniterJQueryAJAXTest/

Files:

/application/controllers/test.php
/application/views/test.php (loaded in by test.php)
/application/controllers/advert/test2.php (loaded in by the test.php view via JQuery ajax)
/application/controllers/test_root.php (loaded in by the test.php view via JQuery ajax)
/application/views/advert/test2.php (loaded in by test2.php)

testapp/application/controllers/test.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class test extends CI_Controller {

        public function index()
        {
            $this->load->view('test');
        }

    }

?>

/application/views/test.php (loaded in by test.php controller)

<!DOCTYPE html>
<html>

    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <title>JQUERY AJAX TEST</title>
        <!-- CSS START -->
        <style>
            html, body {
                font-family: arial;
                font-size: 12px;
            }
            #container {
                width: 100%;
                height: 400px;
                border: 2px solid #000000;
                overflow: auto;
            }
        </style>
        <!-- JS INCLUDES START -->
        <script type="text/javascript" src="<? echo(base_url(" includes/js/jquery/jquery-1.7.2.min.js
        ")); ?>"></script>
        <script type="text/javascript" src="<? echo(base_url(" includes/js/functions.js
        ")); ?>"></script>
        <!-- JQuery AJAX START -->
        <script type="text/javascript">
            function loadPage() {
                $url = $("#url").val();
                var request = $.ajax({
                    type: "post",
                    url: $url,
                    data: "t=1234",
                    success: function (data) {
                        trace("#### SUCCESS ####");
                        $("#container").html(data);
                    },
                    error: function (data) {
                        trace("#### ERROR ####");
                        trace("data = " + data);
                        traceObject(data);
                        traceToDiv("#container", "<h2>#### ERROR ####</h2>");
                        traceObjectToDiv("#container", data);
                    },
                    statusCode: function (data) {
                        trace("#### StatusCode ####");
                        traceObject(data);
                        traceToDiv("#### StatusCode ####");
                        traceObjectToDiv(data);
                    },
                    isModified: function () {
                        trace("#### isModified ####");
                    }
                });
            }
            <!-- JQuery AJAX END -->
        </script>
    </head>

    <body>
        <form id="frm">
            <input type="button" value="LOAD PAGE IN BOX" onclick="loadPage();" />
            <input type="reset" value="RESET" />
            <div id="container"></div>
            <b>JQuery AJAX page url target:</b>
            <input type="text" id="url" value="advert/test2"
            />
            <ol>
                <li>
                    <p>Set
                        <b>url target</b>to "test_root" to test load a root page. (WORKS IN CHROME!)</p>
                </li>
                <li>
                    <p>Set
                        <b>url target</b>to "advert/test2" to test load a 1 dir deep controller page.
                        (FAILS IN CHROME!)</p>
                </li>
                <li>
                    <p>Set
                        <b>url target</b>to "../ci.php" to test load a php page outside of the codeigniter
                        framework. (WORKS IN CHROME?!)</p>
                </li>
            </ol>
        </form>
        <br>
        <h3>Test links</h3>
        <ul>
            <li>Browser test link via index.php/
                <br/>
                <a href="<? echo(base_url(" index.php/advert/test2 ")); ?>"><b><? echo(base_url("index.php/advert/test2")); ?></b></a>
            </li>
            <li>Browser test link direct (needs .htaccess to work)
                <br/>
                <a href="<? echo(base_url(" advert/test2 ")); ?>"><b><? echo(base_url("advert/test2")); ?> </b></a>
            </li>
            <li>Browser test link direct (needs .htaccess to work)
                <br/>
                <a href="<? echo(base_url(" test_root ")); ?>"><b><? echo(base_url("test_root")); ?></b></a>
            </li>
            <li>Browser test link direct
                <br/>
                <a href="../ci.php"><b>../ci.php</b></a>
            </li>
        </ul>
        <br>
        <p>Windows 7x64 - Browser results:</p>
        <ul>
            <li>Chrome - Fail</li>
            <li>IE 9.0.8112.16421 64Bit - Success (Compatability view on & off)</li>
            <li>IE 9.0.8112.16421 32Bit - Success (Compatability view on & off)</li>
            <li>FireFox 14.0.1 - Success</li>
            <li>Opera 12 build 1467 - Success</li>
            <li>Safari 5.1.7 (7534.57.2) - Success</li>
        </ul>
    </body>

</html>

/application/controllers/advert/test2.php (loaded in by the test.php view via JQuery ajax)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class test2 extends CI_Controller {

        public function index()
        {
            $this->load->view('advert/test2');
        }

    }

?>    

/application/views/advert/test2.php (loaded in by test2.php)

Hello I am loaded by JQuery AJAX

../ci.php

<?
    echo("I am a php file echo test from outside of the Codeigniter test site");
?>

Chromes network results are:

http://127.0.0.1/testapp/public/advert/test2 - Method:POST - Status: Failed

Additional

The only ways this code works for Chrome is

  1. If I use a html file outside the CodeIgniter framework for this project the JQuery AJAX load works. Any ideas why that would work in all other browsers bar Chrome?

and

  1. If I place the page which JQuery wants to load at the root of the CodeIgniter website. So “application/controllers/test.php” which loads “application/views/advert/test2.php” will work but “application/controllers/advert/test.php” will not? But works in all other browsers? Chrome status – 0

    Anyone got any ideas?

Give it a try at http://www.allforthecode.co.uk/dev/CodeigniterJQueryAJAXTest/ and try points 1,2 & 3 listed on page and watch console outputs)

ZIP: http://www.allforthecode.co.uk/dev/CodeigniterJQueryAJAXTest/CodeigniterJQueryAJAXTest.zip

  • 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-08T07:34:45+00:00Added an answer on June 8, 2026 at 7:34 am

    Found the problem… Browser adons/plugins…

    If you have adblock installed on either firefox & chrome it will break many AJAX Queries.

    In my case it was “AdBlock”.

    Turn them off and all is fine…

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

Sidebar

Related Questions

I am trying to perform a simple jQuery AJAX attempt using either a .get()
I am trying to perform an ajax.get using jquery within document.ready . But the
I'm trying to perform a simple html request using jquery with the code below.
Im trying to perform a mod rewriting to my web site. And I used
I'm trying to perform the acquisition of data from the internet on the load
I am trying to perform a JNDI-lookup from within the GWT devmode. I have
I am trying to perform a search for documents within a SharePoint site, but
I'm just trying to preform a very simple jQuery action. I have two components:
im trying to perform a simple database insert from a submission on a SilverLight
I am trying to perform a simple URLRewriting. if you visit azamsharp.com it will

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.