JQuery load function different results to URL

The following function triggers a search function and loads their results into a container. For some unknown reason, unlike if one types the URL and query into the browser bar, it only seams to work if their are 5 or more characters in the search.????

function searchelectors(q){
    t=$(q).val().replace(" ","+");
    $('.searchelectors').load('<?php echo 'http://'.$site_url.$site_uri;?>?q=' + t + ' .searchelectors',function(){
        $('.searchelectors .wheel').slideUp(200);   
    });
}

Answers


Encode your querystring value and send it. You can use encodeURIComponent method.

function searchelectors(q){
    t=$(q).val().replace(" ","+");
    t = encodeURIComponent(t);
    $('.searchelectors').load('<?php echo 'http://'.$site_url.$site_uri;?>?q=' + t + ' .searchelectors',function(){
        $('.searchelectors .wheel').slideUp(200);   
    });
}

Need Your Help

Is there an alternative to C# Thread.CurrentThread.CurrentCulture in Java?

c# java localization

Is there an alternative to C# Thread.CurrentThread.CurrentCulture in Java? If not what is the best place to store user selected locale in Java?

LaTex notation in Database (e.g. PostgreSQL) - but rendered for human readability

database latex crud mathjax katex

How can LaTex syntax in database cells (e.g. PostgreSQL) be made human readable as mathematical notation (symbols, greek letters, etc.) on the client-side, maybe with a web-interface? How can this be