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

The Archive Base Latest Questions

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

I just started learning using AJAX with Codeigniter. On my view, I have a

  • 0

I just started learning using AJAX with Codeigniter. On my view, I have a textarea and a button which uses AJAX to submit the text in the textarea to my controller, which retrieves data from the database and returns this data to the view. However I am getting the error “disallowed key characters” in the callback function. This happens even when I simply echo a string. What is happening?

Btw, should I use return $result or echo $result in the controller to pass the data back to the webpage?

AJAX

$(function() {
    $("#search_button").click(function(e){
        e.preventDefault();
        var search_location = $("#search_location").val();
        $.get('index.php/main/get_places', search_location, function(data){
            $("#result").html(data);
            console.log(data);
    });
});

});

Controller

function get_places($address) {

    $search_latlng = $this->geocode_address($address);
    $this->load->model('main_model.php');
    $result = $this->main_model->get_places($search_latlng);

    echo "test";
}
  • 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-26T06:23:11+00:00Added an answer on May 26, 2026 at 6:23 am

    CodeIgniter has restricted the characters in the url to:

    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; //Inside config.php
    

    Chances are you are putting in characters that not in this list in the address when you send the AJAX request. My suggestion would be change the $.get to $.post and then get the post data out in the controller. Something like this:

    AJAX

    $(function() {
        $("#search_button").click(function(e){
            e.preventDefault();
            var search_location = $("#search_location").val();
            $.post('index.php/main/get_places', {'search_location': search_location}, function(data){
                $("#result").html(data);
                console.log(data);
            });
        });
    });
    

    Controller

    function get_places() {
        $address = $this->input->post('search_location');
        $search_latlng = $this->geocode_address($address);
        $this->load->model('main_model.php');
        $result = $this->main_model->get_places($search_latlng);
    
        echo $result;
    }
    

    As for the echo vs return, use echo.

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

Sidebar

Related Questions

I have just started learning to write apps for android using Eclipse. Where can
I've just started learning WPF MVVM using Prism and Unity. Decoupling the view from
I have just started learning how to program Windows GUI's using the low level
I've just started learning Qt, using their tutorial. I'm currently on tutorial 7, where
I have just started learning Erlang and am trying out some Project Euler problems
I've only just started learning to build iPhone apps using xcode. I'm slowly getting
I have just started learning C#. Can anyone explain the technical differences between a
Hello i have just started learning mvc2 and im having a problem with the
I just started learning C++ and am currently using codeblocks. I want to write
I just started learning Zend. I managed to get the basic working (using zf

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.