I have an AJAX request with jQuery "autocomplete", like code bellow:
var clientesList = [];
$("#clientes").autocomplete({
source: function (request, callback) {
$.ajax({
type: "POST",
url: "../../../Cliente/GetClientesByName",
data: "{'nome':'" + request.term + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
debugger;
callback($.map(data.cities, function (obj) {
return obj.Main
}))
}
})
}
})
When the event is triggered, the error is showed in jquery.min??
"Create:2 Uncaught SyntaxError: Unexpected token < in JSON at position 2"
My input HTML is this:
<input type="text" id="clientes" class="form-control col-md-10" />
data
is not valid JSON. Trydata: JSON.stringify({nome: request.term})
. The two could be related (bad data -> HTML error response) – Defeasible<
comes from the fact that you're actually being served a HTML document. – Rooftree