jquery-autocomplete icon indicating copy to clipboard operation
jquery-autocomplete copied to clipboard

Problem with extraParams

Open 4rn0t0m4 opened this issue 12 years ago • 1 comments

Hi there !

I've got a problem I can't solve by myself, I've already try to search on the web without succeed... so I finally post here !

Here is my code :

    $("#search_city").autocomplete({
            url: '/ajax/get_city.php',
            minChars: 3,
            extraParams: {
                dept: function() { return $("#search_dept option:selected").val(); }
            },
            mustMatch: false
        });

When I try to get the value of $_GET["dept"] in my php script "get_city.php" I've got the entire code : "function() { return $("#search_dept option:selected").val(); }" as a string instead of the real value of this field !

Do you have any idea of what append to my script ?

Thanx a lot for your help! Boo

PS : sorry if my english isn't perfect, I did my best...:-)

4rn0t0m4 avatar Apr 14 '12 15:04 4rn0t0m4

You can modify the makeUrlParam function like this:

 var makeUrlParam = function(name, value) {
        if(value != 'undefined' && value != '' && jQuery.isFunction(value))
        {
            value = value();
        }
        return [name, encodeURIComponent(value)].join('=');
    };

CannyDuck avatar Apr 18 '12 13:04 CannyDuck