var dat;
$.ajax({
url: url,
type: 'POST',
dataType: "json",
success: function (data, textStatus) {
dat = data;
alert(data.name);
}
});
I am trying take JSON-encoded data from URL. Here is the response that AJAX receives from the server: http://pastebin.com/53e6CgbK. However, the web browser give me an error:
Uncaught SyntaxError: Unexpected token :
How can to get an attribute from the JSON encoded data?
Most likely you have a syntax error in your code prior to the $.ajax call, such as a missing ‘}’ which makes the javascript engine get out of sync with your intentions and get unexpected “:”.