JSON data not added in jQuery array
$(function() {
$(document).ready(function() {
$.get("automcomplete.php", function(data, status) {
console.log(data);
// echo json_encode($result['name']);
// response
// "Afghanistan""Africa""Albania""Algeria"
var availableTags = [data];
// i want todo this
// var availableTags = [
// "america",
// "london"
// ];
$("#tags").autocomplete({
source: availableTags
});
});
});
});
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
Create auto complete list dynamically and show in the list problem is how i can put json data in jquery array
$(function(){})and$(document).ready(); they are one and the same. and directly assign data to availableTagsdataTypeargument or use$.getJSONto be suredatais parsedechoin a loop and need to create an array and only echo once