My dev environment is LAMP-based (Drupal); there are several JS (jQuery) files that are served up to provide various bits of functionality.
Until recently, things worked fine (well, IE6 was hideous but at least it worked). However, recently, one of my JS files has started to refuse to execute at all in IE6 and IE7.
If the file contains the following, I receive two alerts, reading 'HELLO' and 'GOODBYE':
alert('HELLO');
alert('GOODBYE');
However, when I add in the ready handler, I get exactly zero alerts:
alert('HELLO');
$(document).ready(function(){
alert('AWESOME!!!!!!!!!!!!');
}
alert('GOODBYE');
The odd thing is that my code works fine (e.g. we see 'AWESOME!!!...') in Firefox and IE8. Furthermore, this code used to run fine in IE6/7. TO make things even stranger, the jQuery in other JS files still executes without incident. Perhaps I have too many ready handlers? (I've only got about five... ?)
Any thoughts? I've been battling this for hours, and I have no idea what is going on. Thanks in advance for your help!
UPDATE Thanks to Alconja (below), we determined that the problem was due to a missing paren and semicolon. I fixed the problem in my small bit of test code and the alert()s executed as expected. However, when I went back to my full-scale codebase, the paren/semicolon pair was present. However, given what I had experienced with the short test harness (and the error that I inadvertently introduced while pruning my full-length code down to the test harness), I knew that the problem was due to a syntax error in the javascript. So, I simply went through the file, deleting increasingly large portions of the code until the alert() box showed up.
As was to be expected, the (original) problem was due to a syntax error. My (incorrect) code was:
$.post(
'../ajax/changeUrl',
{
url: url,
},
function(responseText, textStatus, xhr) {
// console.log(this);
// console.log(responseText);
// console.log(textStatus);
// console.log(xhr);
}
);
As you can see, there is an extra comma on the line reading 'url: url,'. Once I removed this comma, the script executed correctly. Of course, Firefox and other browsers didn't barf on this nearly as badly as IE did, and I do know why I inserted this error - it's a bad habit introduced by PHP's lenience with commas in array definitions (or perhaps parameter/variable lists in general as well)...
Anyway, it's fixed! So, thanks again, everyone! :)