SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for a newbe!!!

    Hi to all!

    I have the following script for a Live Search", that runs ok.

    Code:
    /* JS File */
    
    // Start Ready
    $(document).ready(function() {  
    
        // Icon Click Focus
        $('div.icon').click(function(){
            $('input#search').focus();
        });
    
        // Live Search
        // On Search Submit and Get Results
        function search() {
            var query_value = $('input#search').val();
            $('b#search-string').html(query_value);
            if(query_value !== ''){
                $.ajax({
                    type: "POST",
                    url: "search.php",
                    data: { query: query_value },
                    cache: false,
                    success: function(html){
                        $("ul#results").html(html);
                    }
                });
            }return false;    
        }
    
        $("input#search").live("keyup", function(e) {
            // Set Timeout
            clearTimeout($.data(this, 'timer'));
    
            // Set Search String
            var search_string = $(this).val();
    
            // Do Search
            if (search_string == '') {
                $("ul#results").fadeOut();
                $('h4#results-text').fadeOut();
            }else{
                $("ul#results").fadeIn();
                $('h4#results-text').fadeIn();
                $(this).data('timer', setTimeout(search, 100));
            };
        });
    
    });
    The problem is that when you click on one of the results to accept it, it open a new tab; I will like to reload the current.

    Any idea?

    Thanks in advance,

    Juan
    Last edited by Force Flow; Jun 8, 2013 at 20:12. Reason: added code tags


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •