I have this PHP script and it is not working correctly. What mistake?
<?php if(isset($success) || isset($failure)){?> <script type="text/javascript"> $(document).ready(function(){ $('div.aler').css('display','block'); $("div.aler").html("<?php if($success){echo '<p class=\"success\">'.$success.'</p>';}elseif($failure){echo '<p class=\"failure\">'.$failure.'</p>';}; ?>"); setTimeout(function(){ $("div.aler").fadeOut("slow", function (){ $("div.aler").remove(); }); }, 5000); }); </script> <?php }
I think the quotation mark problem is. " $failure has a message, but Javascript doesn't put it in the HTML div div.aler . I get this error message in the Chrome console:
Uncaught SyntaxError: Unexpected ILLEGAL Token
source share