Database LiveSearch |
[eluser]joe.afusco[/eluser]
Pretty new to PHP and CodeIgniter. Not sure that I am even doing this the best way possible. Attempting to live search a database, so when a user begins typing in a search field, the results populate in a div. Followed this video: http://www.youtube.com/watch?v=mSAbp_4ACaw Here is what I have so far. My search is calling the javascript function: Code: <input type="text" class="search-query" placeholder="Search" /> Although, it seems when I wrap code tags, it hides my onkeyup event. But it is there. Javascript function: Code: function getSearchResults(value) { And the php file that searches: Code: <?php Can't seem to spot the error. Note, these are all 3 on separate files, not sure if that is the issue. Search is in navigation.php view, which is loaded on every page, the javascript is in the main user view which loads the navigation, and the php is a separate file all together, in the same directory as these views. Any help on this, or any better way of trying to accomplish the task would be much appreciated.
[eluser]sanir[/eluser]
hi, can you put complete code of your view file. Thanks, Nasir Ranta
[eluser]joe.afusco[/eluser]
Main view file: Code: <!DOCTYPE html>
[eluser]sanir[/eluser]
please confirm did u use jquery file in your view file Thanks, Nasir Ranta
[eluser]joe.afusco[/eluser]
Hmm. Keeps kicking errors when I try to post my navigation.php contents. The only relevant bit of that file should be the search box, which I previously posted.
[eluser]joe.afusco[/eluser]
[quote author="sanir" date="1338386410"]please confirm did u use jquery file in your view file [/quote] Yes, it is on there.
[eluser]sanir[/eluser]
Code: $partialSearch = $_POST['partialSearch']; try this code.
[eluser]joe.afusco[/eluser]
Still nothing being generated. I tested my onkeyup event with an alert, so I know it is at least making it that far. I have my database autoloading, so I assume it isn't a db connection issue. Not sure what else it could be.
[eluser]boltsabre[/eluser]
Use firebug (firefox plugin) and it's "console" tab, it will give you some error messages. Do you have CSRF autoloaded? This can play havoc with jQuery/ajax requests.
[eluser]joe.afusco[/eluser]
It issues the following error: POST http://localhost/crm/index.php/getSearchResults.php 404 Not Found Is there a specific place I should put this file so it can find it? Not sure of the best way to follow the mvc pattern with this function. No CSRF is not autoloading. |
Welcome Guest, Not a member yet? Register Sign In |