How to format JSON data
How to format JSON data
Hi there,
Here is my jQuery function that returns an array of emails. Autocomplete shows the returned array of emails as I type in a text box in a form of bullet list. How do I change the form so that I can get rid of bullets. Here is my code
- <script>
$(function () {
$('#Email').autocomplete({
source: function (request, response) {
var options = {};
options.async = true;
options.url = "/Home/GetEmails";
options.type = "POST";
options.data = JSON.stringify({ term: request.term });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (ADEmails) {
response(ADEmails);
};
options.error = function (jqxhr, status, exception) {
console.log('jqxhr: ' + jqxhr);
console.warn('jqxhr.responseText: ' + jqxhr.responseText);
console.log('status: ' + status);
console.log('error: ' + exception);
}
$.ajax(options);
},
}).autocomplete("instance")._renderItem= function( ul, item) {
console.log(item);
return $('<li/>')
.attr('data-value', item.value)
.append( item.label )
.appendTo( ul );
};
});
</script>
The returned data is in the format: ["
Jane@domain.com", "
john@domain.com"]
Thanks in advance.
Joe