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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:05:50+00:00 2026-06-10T23:05:50+00:00

So here is my problem in localhost. I am passing in the search parameter

  • 0

So here is my problem in localhost. I am passing in the search parameter to my Home controller like:

<form method="post" action="<?=site_url('home/index');?>"> 

When I do this, my ajax menu is populated correctly

       ----------
SEARCH:| mot    |
        ----------------------------
       | motorcyles ...            |
       | motorhomes ...            |
       | motorola ..               |
       -----------------------------

.

On my web server, the only way to submit the form is with <form method="post" action="<?site_url('home/index');?>"> if I put the “=” in there, it does nothing. If I use

<?php echo site_url('home/index');?>"> 

it will also display nothing.

Additionally, when I type in search terms on my web server

        ----------
 SEARCH:| mot    |
         ---------

nothing, no errors, no results. If I submit the form, I get back the correct results only after pressing submit.

My controller is getting the correct results from the database, here is how I’m encoding my results array:

if ( $this->input-> is_ajax_request())
    {
        $this->output->set_header("Cache-Control: no-cache, must-revalidate");
        $this->output->set_header("Expires:Mon, 4 Apr 1994 04:44:44 GMT");
        $this->output->set_header("Content-type:application/json");

        echo json_encode($results);
        exit();

    }

    else {

        $data['results'] = $results;

         }

There are no errors with my js file. I have CSRF turned off. Why is this happening?

$(document).ready(function() {

    var action= $('form').attr('action');
    var results = $('#results');

    function ajax_search(search) {

        $.post(action, {
            search: search
        }, function(data) {

            if(data.length) {

                var el = $('<ul/>');

                $.each(data,function(i,item){
                    $(el).append('<li><span class="Course_Name">' + 
                    item.course_name_highlighted + '</span> &ndash; <span class="FirstName">' + item.FirstName + '</span> &ndash; <span class="LastName">' 
                    + item.LastName + '</span> &ndash; <span class="COURSE_ID">'+item.COURSE_ID +'\n</span></li>');
                });

                $(results).empty().append(el);
            }



            else{
                $(results).empty();
            }
        }, 'json');

    }




    $('#search').keyup(function() {

        var search = $(this).val().replace(/^\s+l\s+$/g, "");

        if(search.length > 1)

        {
            clearTimeout($.data(this, 'timer'));

            var wait = setTimeout(function() 
            {
                ajax_search(search)

            }, 400);

            $.data(this,'timer', wait);
        }

    });

});
  • 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-10T23:05:51+00:00Added an answer on June 10, 2026 at 11:05 pm

    Rather than an form submission you want the results to display after a keyup event correct(ie: when someone types) ?

    Try

    $("input[name='search']").on('keyup', function(){
    
         var $this = $(this),
             results = $("#results"),
             timeout = '';
    
         // ------ delayed keyup event  ------//
    
         //reset initial timeout
         if(timeout)
         {
             window.clearTimeout(timeout);
             timeout = NULL;
         }
         // ------Timeout Listener ----- //
         timeout = window.setTimeout(function(){
            //send ajax request
            var searchTerm = $this.val();
    
         }, 1000);  // listens for when last key has been pressed after 1sec
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with my localhost website. So I explain here my problem,
The problem here is how to add an NSPopUpButton in Xcode 4's Interface Builder
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
date here my problem: String datetime = 2012-03-24 23:20:51; I know that that string
Super weird problem here. I'm having trouble getting jQuery to bind any selectors except
I have a problem here im trying to upload a file first time it
Im having a problem here. i downloaded jake wharton. He gave an example of
What is the problem here? (Besides having redundant code). $.getJSON works as expected. However
I have a problem here. My Zend_Forms do not render in view script. Via
I have a problem here I can't solve. I have a database of houses

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.