Scalalang2
Scalalang2

Reputation: 546

I have got an invalid json error

code :

var data = $.parseJSON(data);

Error message :

Uncaught Invalid JSON: {times: [{'9:30am','10:00am','10:30am','11:00am','11:30am','12:00pm','12:30pm','1:00pm','1:30pm','2:00pm','2:30pm','3:00pm','3:30pm','4:00pm','4:30pm','5:00pm'}]} 

I have tried to parse as json at Ajax,

then I don't understand why this error is appeared.

Please tell me about it.

Thanks

Upvotes: 0

Views: 134

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324810

Remove the {} around the array's contents, and use double-quotes around the strings. Your JSON should be:

{"times":["9:30am","10:00am"......]}

Upvotes: 3

Related Questions