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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:31:52+00:00 2026-05-15T20:31:52+00:00

THIS PROBLEM IS NOW SOLVED. THANK YOU TO EVERYONE WHO REPLIED. Hello, I am

  • 0

THIS PROBLEM IS NOW SOLVED. THANK YOU TO EVERYONE WHO REPLIED.

Hello,

I am trying to solve a problem that I may have approached from the wrong direction, so maybe someone could suggest a better solution.

I am writing a little web app for work, that has a search function. When user submits a search string, form gets posted to a CodeIgniter controller. If search returns a result, CodeIgniter loads a page with results. If there is no results, user’s current page just gets reloaded, without any indication that search returned no results. So, this is not user friendly at all and i decided to re-do that with some help from $.ajax().

That was rather easy, but now I am stuck trying to figure out what to do with the data i receive back, if search is successful.
I know $.load() can replace a part of the page, but i need to redirect the user to a completely different page, while POSTing the data
my ajax search just returned. The data that comes back from PHP is in json_encode() format.

NOTE: $.jGrowl() is a jQuery plugin that displays a Growl-like message.

$("#alias_s").submit(function() {

    event.preventDefault();
    var term = $('input#alias_search').val();

    $.post("<?=base_url()?>aliases/searchAliases", { 
         searchTerm: term }, 
         function(data) { 
             if(!data) {
               $.jGrowl("Search for '" + term + "' returned no results", { life: 5000 });;
             } else {
               //
               //  How do i post this data to another page and redirect a user there?
               //
             }
});

UPDATE: I managed to find a work-around to this issue.

I take the data that was returned from $.post() and use $.load() to POST it back to the same controller, that in turn takes the data and loads correct view files. The only downside is that URL it still the same, which breaks couple of small things, but I can deal with that…

$('#content').load("<?=base_url()?>aliases", { searchData: data});

UPDATE #2: I finally made it work like i wanted. What i did, is take the data that was returned from PHP in JSON format, post it back to the same controller, and let CodeIgniter take care of loading views, this way all my URL dependent stuff works too.

$('<form action="CONTROLLER" method="post"><input type="hidden" id="searchData" name="searchData" value='+data+'></form>').appendTo($("body")).submit();

There were 2 caveats though.

  1. appendTo($("body")) was needed to make it the form submit correctly in Firefox.

  2. POST was cutting off my JSON string after first space, so i had to use str_replace() in php do fix that.

    echo str_replace(‘ ‘, ‘%20’, json_encode($search_results));

THIS PROBLEM IS NOW SOLVED. THANK YOU TO EVERYONE WHO REPLIED.

  • 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-15T20:31:52+00:00Added an answer on May 15, 2026 at 8:31 pm

    This has been solved. Solution is in my original post.

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

Sidebar

Related Questions

i have this problem that i can't solve for days now...here is my code.
This problem has been kicking my butt for a few days now. I have
This problem crops up every now and then at work. Our build machine can
This originally was a problem I ran into at work, but is now something
This problem has been solved thanks to your suggestions. See the bottom for details.
This problem involved me not knowing enough of C++. I am trying to access
Consider this problem: I have a program which should fetch (let's say) 100 records
i tried now nearly everything i could to solve he following problem. So far
I have come across a very odd problem in C that I have never
Edit (Solution Discovered) Thanks everyone for your help on this. The problem was an

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.