How to use different pages for form input and results using AJAX
<p>So, I have a search form in a php page (top.php) which is an include for the site I'm working on, one php page where all the mySQL stuff happens and the results are stored in a variable and echoed (dosearch.php) and lastly a php page where the results are displayed in a div through jQuery (search.php). This is the javascript code: </p>

<pre><code>$(document).ready(function(){
    $('#search_button').click(function(e) {
        e.preventDefault(); 
        var searchVal = $('#search_term').attr('value');
        var categoryVal = $('#category').attr('value');
        $.ajax({
            type: 'POST',
            url: 'dosearch.php',
            data: "search_term=" + searchVal + "&amp;category=" + categoryVal,
            beforeSend: function() {
                $('#results_cont').html('');
                $('#loader').html('&lt;img src="layout/ajax-loader.gif" alt="Searching..." /&gt;');
                if(!searchVal[0]) {
                    $('#loader').html('');
                    $('#results_cont').html('No input...');     
                    return false;
                }   
            },
            success: function(response) {
                $('#loader').html('');
                $('#results_cont').html(response);
            }
        });
    });
});
</code></pre>

<p>The #search_term and #category fields are in top.php, the other divs (#loader and #results_cont) are in search.php. How would I go by in order to make the form submit and display the results in search.php from the top.php without problems? It works perfectly if the form and javascript are in search.php but I can't seem to separate those and make it work. What am I doing wrong?</p>

<p>PS. Sorry if I'm not clear enough, am at work, really tired. :(</p>
