Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to debug jQuery AJAX
    text
    copied!<p>I'm using Chrome to debug my websites. However, sometime I come up with errors like this one:</p> <p><strong>Error</strong></p> <pre><code>Uncaught TypeError: Cannot set property 'display' of undefined </code></pre> <p><strong>Stack Trace</strong></p> <pre><code>f.extend.ajax ClassLoader.performLoadWave </code></pre> <p>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. </p> <p>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?</p> <p><strong>EDIT</strong> </p> <p>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?</p> <hr> <p><strong>Code</strong></p> <p>For anyone that cares about my code, here it is:</p> <pre><code>$.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] &amp;&amp; window[className]['included']) { window[className]['included'](); } className = 'Plugin_' + element.className; if(window[className] &amp;&amp; window[className]['included']) { window[className]['included'](); } className = 'Plugin_Administration_' + element.className; if(window[className] &amp;&amp; window[className]['included']) { window[className]['included'](); } if(element.completed) { element.completed(); } } }); ClassLoader.isLoading = false; } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload