In JSON, “Unexpected token o”

 

In the html file I have:

$.ajax({

type: “GET”,

datatype: “‘json’,

url: ‘/try/retr’,

success: function(data){

var obj = JSON.parser(data)

alert(obj.data)

}

});

This code gave the error:

Uncaught SyntaxError: Unexpected token o

Error is once declared as datatype json, it parses for you.

so :

var obj = JSON.parser(data)

success: function(data){

var obj = JSON.parser(data)

alert(obj.data)

}

and bingo :)

 

 

About these ads

One thought on “In JSON, “Unexpected token o”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s