I have the following code, which did work fine until just now, event.preventDefault(); doesn't seem to trigger in FireFox? In Chrome the code still works fine, in Firefox however, it takes me to blank page and I see generated code there instead.
$("#generate_code").click(function(){
event.preventDefault();
$('#code').html('Generating Code..');
hideshow('loading',1);
setTimeout(function() {
$.get("generate-code.php", function(data) {
$("#code").html(data);
});
hideshow('loading',0);
}, 2000);
});
generate-code.php:
function generateRandomString($length = 50) {
$characters = '!@#$%^&*()0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
$invitecode = generateRandomString();
echo $invitecode;