I have a jquery json ajax call and inside my success function I have the following check:
if(data['error'] === 1) {
$return_feedback.html(data['error_msg']);
}
For some reason I can’t seem to understand though right now, I’m getting an error:
'Uncaught TypeError: Cannot read property 'error' of null'
And refers to the if(data[‘error’] line of code above.
So I’ve looked at what my script is returning and it is true – there is no data. But then shouldn’t it just skip this if statement altogether? Or am I supposed to check if the data value exists first before calling an if statement?
Thanks for your time on this.
data is null
use this: