I'm fetching some data from a server, and i have them returned in json as objects.
My ajax request is the following:
$.ajax({
url: Url,
dataType: 'json',
success: function (result) {
var obj = JSON.parse(result)
$(".result").text(obj);
}
})
If i try to use JSON.parse(result), it returns an error: Unexpected token o but on my network tab has the result element correct:
{service: "29”,…}
{service: “33",…}
{service: “45”,…}
{service: “70",…}
If i don't use JSON.parse(result), what i have printed is the following:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
what am i doing wrong? Thanks
EDIT:
if i use this code here:
$.ajax({
url: Url,
dataType: 'json',
success: function (result) {
console.log (result)
$(".result").text(result.service);
console.debug (result.service);
}
})
The first console has the following results:
0: Object
service: "29"
__proto__: Object
1: Object
service: "29"
__proto__: Object
but nothing is printed in the div, and the second console is undefined