Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bloodhound remote may not be honoring AJAX type: POST #630

Closed
Morgon opened this issue Feb 2, 2014 · 2 comments
Closed

Bloodhound remote may not be honoring AJAX type: POST #630

Morgon opened this issue Feb 2, 2014 · 2 comments

Comments

@Morgon
Copy link
Contributor

Morgon commented Feb 2, 2014

Congrats on the release of 0.10!

I'm having some trouble migrating my TTA code from the previous version. It's my understanding that Bloodhound takes a jQuery AJAX Options object; one option changing the default GET to another verb.

I cannot seem to get Typeahead to POST to my endpoint. When I use other options, like 'data', it definitely does use that in a querystring, leading me to believe the object is being considered.

    var userInterests = new Bloodhound({
        // Tokenizers pulled from the examples; admittedly not sure what they do :) 
        datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.value);  },
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        remote:   {
            url:        "/path/to/searchWithPost",
            replace:    function (url, query) {
                // Pulled from Issue #542 to ensure endpoint is not cached by TTA
                return url + "#" + query;
            },
            ajax: {
                type: 'POST',
// With 'data', I can watch a GET request to my endpoint with a '?q=' querystring
// Commented, there's no querystring. So I can only deduce this *is* being read.
                data: $.param({q: $('#interest-input').val()})
            }
        }
    });

I've only been using Typeahead for a few days as it is, so it's possible I'm missing something basic. Any direction you can point me in would be wonderful.
Thanks!

@Morgon
Copy link
Contributor Author

Morgon commented Feb 2, 2014

Ah. After reading through the code, it looks like you're checking ajax.method, rather than ajax.type.

This is a different expectation than the jQuery AJAX settings that the Bloodhound docs link to, which uses 'type' to set the HTTP verb.

Is this intended?

@jharding
Copy link
Contributor

jharding commented Feb 2, 2014

Oh wow, what a dumb mistake. Definitely not intended. My guess is a handful of these issues are going to be found with v0.10.0 since it was a major rewrite, so the turnaround for v0.10.1 is going to be pretty short, maybe a week or two. I want to make sure I get these issues resolved ASAP. Thanks for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants