WordPress.org

Forums

jQuery Autocomplete Not Working in Chrome/Firefox (1 post)

  1. Mjedrzejczyk
    Member
    Posted 1 year ago #

    Hello,

    I've made use of the code at https://github.com/stephenh1988/WordPress-AutoComplete-Search to add autocomplete to my WordPress search.

    (It's based on the tutorial at: http://wp.tutsplus.com/tutorials/theme-development/add-jquery-autocomplete-to-your-sites-search/)

    It works in Safari and does nothing in Chrome and Firefox.

    Unfortunately, I have limited knowledge of javascript. I'm assuming that the problem lies in the following code since, clearly, the backend is doing its job and I'm getting results in Safari.

    <script type="text/javascript">
    	jQuery(document).ready(function ($){
    		var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
            	var ajaxaction = '<?php echo self::$action ?>';
            	$("#secondary #searchform #s").autocomplete({
    			delay: 0,
    			minLength: 3,
    			source: function(req, response){
    				$.getJSON(ajaxurl+'?callback=?&action='+ajaxaction, req, response);
    			},
                		select: function(event, ui) {
                    		window.location.href=ui.item.link;
                		},
            	});
       	 });
        </script>

    Anyone have an idea of what the problem is?

Topic Closed

This topic has been closed to new replies.

About this Topic