Open jektvik opened 7 years ago
{ "id": 4, "name": "Arnie Sch", "isSubscribedToNewsletter": true, "membershipTypeId": 1, "membershipType": { "id": 1, "name": "first" }, "birthdate": null }
remove inside suggestions.js [] its works me, even i m searching some MIME issue.. HTML should be this
<link rel="stylesheet" href='http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css' media="screen" />
<link rel="Stylesheet" href="https://twitter.github.io/typeahead.js/css/examples.css" />
<script src='http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
<script src="https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"></script>
The below code will not work if the server doesn't filter responses based on the QUERY. If remote is replaced by prefetch, it will work fine.
`var customers = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: '/api/customers?query=%QUERY', wildcard: '%QUERY' } });
The AJAX request is sent and received properly for example like below:
[ { "id": 4, "name": "Arnie Sch", "isSubscribedToNewsletter": true, "membershipTypeId": 1, "membershipType": { "id": 1, "name": "first" }, "birthdate": null }, { "id": 5, "name": "Sly Stallone", "isSubscribedToNewsletter": true, "membershipTypeId": 1, "membershipType": { "id": 1, "name": "first" }, "birthdate": null }, { "id": 6, "name": "Hugo Weaving", "isSubscribedToNewsletter": true, "membershipTypeId": 1, "membershipType": { "id": 1, "name": "first" }, "birthdate": null }, { "id": 7, "name": "Natalie Portman", "isSubscribedToNewsletter": true, "membershipTypeId": 2, "membershipType": { "id": 2, "name": "second" }, "birthdate": "1995-05-05T00:00:00" }, { "id": 9, "name": "Jason Statham", "isSubscribedToNewsletter": true, "membershipTypeId": 2, "membershipType": { "id": 2, "name": "second" }, "birthdate": "2000-01-01T00:00:00" } ]
But the script does not yield any suggestions:
However, as stipulated in the first paragraph, if the server controller is modified to return only responses based on the sent query(wildcard) the suggestions appear as they are meant to.