Q695 Posted July 28, 2015 Share Posted July 28, 2015 I'm struggling to produce results to the screen from the following code: HTML: <script src="http://code.jquery.com/jquery-2.1.4.js"></script> <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <script src="../scripts/autocomplete.js"></script> <div> <input type='text' class='search_input' name='search' id='search' placeholder='search' autofocus onkeypress='search_func("http://webfarm.io/subs/homefront/list_articles.php" , "search_output")'> <div id='search_output' class='search_output'></div> </div> Javascript: function search_func( href , target){ var search = $("#search").val(); search = $.trim(search); if(search){ $.ajax({ method: "POST", url: href , data: { search: search } }) .done(function( msg ) { target.innerHTML = msg; // as above, data holds the result of the request, so all the data returned from your results.php file are in this param but please see below; console.log(msg); }); } else { target.innerHTML = ''; } } What am I doing wrong? Why won't it produce the desired results?Sorry if I'm looking like a help vamp, but I'm not trying to be. Quote Link to comment https://forums.phpfreaks.com/topic/297501-jquery-auto-complete-producing-results-bug/ Share on other sites More sharing options...
Solution requinix Posted July 28, 2015 Solution Share Posted July 28, 2015 target is merely the string "search_output". Not the element. Quote Link to comment https://forums.phpfreaks.com/topic/297501-jquery-auto-complete-producing-results-bug/#findComment-1517510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.