uploadPicture{"errors":["This file was already uploaded"]} isn't valid JSON
and even var JSON = eval("("+data+")"); resulting in (uploadPicture{"errors":["This file was already uploaded"]} ) isn't valid JSON... hence eval() and expecting it to act like an object is never going to work On Jul 1, 8:55 am, theozmanbo <b.k.osbo...@hotmail.com> wrote: > Okay - well here's what I'm really doing. I'm using an ajax upload plugin and > in the callback function, which returns a variable "data", I need to parse > it into a JSO so I can use it. Right now it's just a string. > > onComplete: function(file, data) { > $('#uploadPics').show(); > $('#loader').hide(); > > // evaluate response > var JSON = eval("("+data+")"); > > if (JSON.messages) { > // display messags > displayAlert(JSON.messages[0], "message"); > } else { > displayAlert(JSON.errors[0], "error"); > } > > } > > NONE of the code gets run after the eval line. I try putting in alerts > before it and after it and only the ones before it show up. I looked at the > javascript console in chrome and there are no errors. The "data" that gets > returned looks like this: > > uploadPicture{"errors":["This file was already uploaded"]} > > so when I eval it, it should give me an object and I can refer to > JSON.messages[0] and whatnot > -- > View this message in > context:http://www.nabble.com/simple-JSON-parse-problem%21%21%21-tp24283450s2... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.