It's failing for browsers that do not have console
object - IE for example.
Just wrap it with try..catch
and it will work for all browsers:
$('#form').submit(function() {
try {
console.log('send');
}
catch (e) {
}
return false;
});
Live test case.
Edit: better yet, you can write your own function to show the message even for browsers without console:
function Log(msg) {
if (typeof console != "undefined" && console.log) {
console.log(msg);
} else {
var myConsole = $("MyConsole");
if (myConsole.length == 0) {
myConsole = $("<div></div>").attr("id", "MyConsole");
$("body").append(myConsole);
}
myConsole.append(msg + "<br />");
}
}
$('#form').submit(function() {
Log('send');
return false;
});
This will append the message to the document itself when console is not available. Updated fiddle.