Welcome Guest, Not a member yet? Register   Sign In
URI disallowed characters + Lucence Search
#1

[eluser]weetstraw[/eluser]
Hello,

I am using the Lucene search feature as explained on andrewrowland.com. When I type a search into the field, #quickresult returns the URI disallowed characters error. Does anyone know why this is happening?

Search Controller
Code:
function result()
{
    $data=array(
        'pageTitle' => '- Search Results',
        'headerImage' => 'search-results',
        'menu' => array('sector'),
        'boxes' => array('search'),
        'results' => array(),        
    );

    if ($this->input->post('search_query'))
    {
        $index = Zend_Search_Lucene::open($this->search_index);
        $data['results'] = $index->find($this->input->post('search_query'));
    }
    
    $this->load->view('search_view', $data);
}

In the View
Code:
<form method="post" action="<?php echo base_url(); ?>search/result">
    <p>
        &lt;input id="search_query" name="search_query" class="textbox" type="text" /&gt;
        &lt;input name="search" class="button" value="Go" type="submit" /&gt;
    </p>
&lt;/form&gt;
<div id="quickresults">
    <p>Type in the search box for quick results.</p>
</div>

Search JS
Code:
$(document).ready(function(){
    $("#search_query").bind("keyup", function(e){
        $.post("&lt;?php echo base_url(); ?&gt;search/menuResult", {search_query: $(e.target).val()},
            function(result_list){
                $("#quickresults > *:not(h3)").remove();
                $("#quickresults").append(result_list);
            });
    });

    $("#search_query").bind("focus", function(e){
        $("#quickresults").slideDown("fast");
    });

    $("#search_query").bind("blur", function(e){
        if (!$("#quickresults ul").length){
            $("#quickresults").slideUp("fast");
        }
    });
});

.htaccess
Code:
DirectoryIndex index.php

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|swf|xml|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#2

[eluser]bretticus[/eluser]
Is there a reason your javascript is posting to menuResult instead of result ?

Code:
$.post("&lt;?php echo base_url(); ?&gt;search/menuResult", {search_query: $(e.target).val()},
#3

[eluser]weetstraw[/eluser]
My error. There is no difference when corrected.
#4

[eluser]bretticus[/eluser]
If you don't have firebug installed already, get it and install it. In the "net" tab you should be able to see these requests. What is the URL being submitted by the javascript?
#5

[eluser]weetstraw[/eluser]
For search.js:

Response Headers
Date Wed, 16 Sep 2009 20:18:54 GMT
Server Apache/2.2.8 (Win32) PHP/5.2.6
Connection Keep-Alive
Keep-Alive timeout=5, max=100
Etag "20500000001a7f8-208-473b67b7a7d38"

Request Headers
Host localhost
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Accept */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Referer http://localhost/wrt-demo/people/title/1
Cookie ci_session=a:4:{s:10:"session_id";s:32:"c4abb47a1973c742a04df29d2af3071e";s:10:"ip_address";s:9:"127.0.0.1";s:10:"user_agent";s:50:"Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv";s:13:"last_activity";s:10:"1253132310";}62792c59e48ee1d7b07f63297f390e80
If-Modified-Since Wed, 16 Sep 2009 18:58:19 GMT
If-None-Match "20500000001a7f8-208-473b67b7a7d38"
Cache-Control max-age=0
#6

[eluser]bretticus[/eluser]
Have a look at the actual request line in firebug that shows where the POST was sent (you can mouse over it or click on it to get the full url.) I suspect there is a query string.
#7

[eluser]weetstraw[/eluser]
Got it! Stupid mistake...

in this line
Code:
$.post("&lt;?php echo base_url(); ?&gt;search/menuResult", {search_query: $(e.target).val()},

I was echoing out the base_url() BUT it's a JS file. This code used to be on a PHP page and I just copy/pasted it to a js file.

Thanks again!




Theme © iAndrew 2016 - Forum software by © MyBB