1
I have an ASP.NET MVC project and in it a script for autocomplete using typeahead with Prefetch:
$(document).ready(function () {
// Sonstructs the suggestion engine
var ativos = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
// The url points to a json file that contains an array of country names
prefetch: 'ativos.json'
});
// Initializing the typeahead with remote dataset
$('.typeahead').typeahead(null, {
name: 'ativos',
source: ativos,
limit: 7 /* Specify maximum number of suggestions to be displayed */
});
});
And the JSON file in the same folder, in the form: ["petr4","usim5","itub4"]
the error I’m getting on the console :
Failed to load Resource: the server responded with a status of 404 (Not Found)
I don’t understand why the script can’t get the JSON file. I think I must make some call via AJAX to return this JSON but I do not know how it would look. I thank you from now on.
AEEE CARA, it worked -, but I had to put the JSON file on the project root!!
– Mário