Reputation: 1221
I see a lot similar questions for this particular javascript error, but my issue is I've already implemented the "fixes" and it still occurs, but only randomly.
The error: Uncaught TypeError: Cannot read property 'status' of undefined
Before referencing the status property like so json.status, in all instances I precede it with:
if ( typeof json.status != 'undefined' )
So in theory, there should be no reason for it to ever throw that error if I'm checking first in all situations.
When I click the line number it's referencing in the console, it goes to a blank screen, so it's been hard to troubleshoot. If I expand open the error stack thing, it references my jquery dataTables a bunch, but I don't know if that's because something is failing prior to it or not.
How can I troubleshoot this deeper, or catch that error properly so it doesn't halt all my AJAX calls that come after it? (requires a refresh when it happens...)
Upvotes: 0
Views: 5883
Reputation: 5738
Cuz you're not providing the full code, I cannot understand so clearly your situation.
Anyway, the error simply showing that json
is undefined (due to something wrong in the coding logic, ...).
To quick fix the error, you can change your code to do null-check for json
as well:
if (json && (typeof json.status != 'undefined')) {...}
Or a better way:
if (json && json.status) {...}
Upvotes: 1