I am trying to pull an error message from an external errors.txt file.
The contents of errors.txt is:
var data = {
'errors': [{
"code": "9999",
"message": {
row: 1,
col: 0,
data: 'ABC',
code: 20016,
message: 'Invalid code.'
}
},
{
"code": "9999",
"message": {
row: 1,
col: 0,
data: 'DEF!',
code: 20016,
volume: '100',
message: 'Invalid code.'
}
}],
"data": {
"report": null
},
"successMsg": null,
"errorMsg": null
}
I am trying to display the message (ie - "invalid code') and have tried the following, but no luck:
jQuery.getJSON('/js/errors.txt', function (data) {
// data is an array of objects
$.each(data, function () {
alert(this.errors[0].message[0].message);
});
});
What am I doing wrong?
"var data = "which is not a valid JSON. Try to remove"var data = "