I want to differentiate between server response, json based or pure text. So in my ajax call I've:
success: function(resp) {
//
json = $.parseJSON(resp);
if (typeof json == "object") {
console.dir(json);
} else {
console.dir(resp);
}
//
}
Problem is, it breaks on Parse line, so I can never reach line where I check typeof...
Uncaught SyntaxError: Unexpected token
What am I doing wrong?
p.s. resp is sometimes json, sometimes pure text.