I'm using Chrome to debug my websites. However, sometime I come up with errors like this one:
Error
Uncaught TypeError: Cannot set property 'display' of undefined
Stack Trace
f.extend.ajax
ClassLoader.performLoadWave
So, I know that it's something in my Ajax call, probably in my success function. But, my success function calls a lot of things.
I'm not really looking for someone to help me debug my code, but just asking how I could debug this. I use a lot of console.log(); but they're not really helpful, how can I properly find errors like this one?
EDIT
To add to my question, in this example, the error is in a file that gets loaded by my AJAX call, since the dataType is set to 'script', but how can I know this without having to dig up for a few hours?
Code
For anyone that cares about my code, here it is:
$.ajax({
url: filePath,
async: false,
cache: !Settings.debugging,
dataType: 'script',
error: function(httpRequest, message, errorThrown){
if(errorThrown == 'Not Found')
{
throw 'Include cannot be found.';
}
else
{
throw errorThrown + ': ' + (message == 'parsererror' ? 'This doesn\'t look like JavaScript!' : message);
}
},
success: function(){
$.each(newNeedsLoading, function(index, element){
if(element !== undefined)
{
var className = element.className;
if(window[className] && window[className]['included'])
{
window[className]['included']();
}
className = 'Plugin_' + element.className;
if(window[className] && window[className]['included'])
{
window[className]['included']();
}
className = 'Plugin_Administration_' + element.className;
if(window[className] && window[className]['included'])
{
window[className]['included']();
}
if(element.completed)
{
element.completed();
}
}
});
ClassLoader.isLoading = false;
}
});