Uncaught SyntaxError: Unexpected token o

Spread the love

If you have an error ‘Uncaught SyntaxError: Unexpected token o’ when you trying parse json using function JSON.parse() it means that you received parsed object and don’t use JSON.parse(). You can use received data as an object.

Example:
$.ajax({
type: “GET”,
url: ‘your_url’,
contentType: ‘application/json’,
dataType: ‘json’,
data: { ‘your_data’: your_data},
success: function (result) {
if (result.myobject !== null) {
alert(result.myobject);
},
error: function (jqXHR, textStatus, error) {
var re = jqXHR;
}
});

Добавить комментарий