Bug fix for getJSON call

Matt's Avatar

Matt

29 Aug, 2011 07:13 PM

Hi,
This is an awesome plugin! But there's a bug in the keyChange function -- it doesn't construct the URL correctly if the URL already contains GET parameters. To fix this, find this line:

$.getJSON(req_string+"?"+opts.queryParam+"="+encodeURIComponent(string)+limit+opts.extraParams, function(data){

And replace it with this:
$.getJSON(req_string, opts.queryParam+"="+encodeURIComponent(string)+limit+opts.extraParams, function(data){

Then jQuery will automatically add either a ? or a & as appropriate.

  1. 1 Posted by Joe Mocker on 02 Sep, 2011 06:24 PM

    Joe Mocker's Avatar

    I think Drew has a provision for this with the extraParams option.

    So doing something like this is wrong:

       $("#geos").autoSuggest("suggestJson.php?filter=all", {
            queryParam: "keyword",
        }
    

    This is how you should do it

       $("#geos").autoSuggest("suggestJson.php", {
            queryParam: "keyword",
            extraParams: "&filter=all",
        }
    

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac