Mudsaf Posted January 30, 2015 Share Posted January 30, 2015 (edited) Hello, i'm wondering what could be the reason that my jQuery wont execute while echoing, but manual execution on browser console works. Code in PHP (This code will still open the window on manage=true, no errors on console) echo "<script>$(function() { $('#message_area').html('The file you try to remove does not exist.').fadeIn(500, function() { setTimeout(function () { window.open('?manage=true', '_self'); <!-- This executes, this comment is not on the code --> }, 2000); });});</script>"; Message area html below. <div id="message_area"><strong>Note</strong>:Enable JavaScript for more advanced website surfing.</div> Edited January 30, 2015 by Mudsaf Link to comment Share on other sites More sharing options...
Ingolme Posted January 30, 2015 Share Posted January 30, 2015 Does the Javascript console have any messages? Most browsers let you see the console by pressing F12. Link to comment Share on other sites More sharing options...
Mudsaf Posted January 30, 2015 Author Share Posted January 30, 2015 (edited) No errors or notifications, added console.log("3"); before $(function() { }); and it displays. Edited January 30, 2015 by Mudsaf Link to comment Share on other sites More sharing options...
Ingolme Posted January 30, 2015 Share Posted January 30, 2015 How about logging the console inside the function? Link to comment Share on other sites More sharing options...
thescientist Posted January 30, 2015 Share Posted January 30, 2015 I would also add logging inside the function. I would do right on the first line and inside setTimeout. Link to comment Share on other sites More sharing options...
Mudsaf Posted January 30, 2015 Author Share Posted January 30, 2015 It logs it normally. Link to comment Share on other sites More sharing options...
thescientist Posted January 30, 2015 Share Posted January 30, 2015 Show us the code you have now that reflects the logging you have added in those additional places. Link to comment Share on other sites More sharing options...
Mudsaf Posted January 30, 2015 Author Share Posted January 30, 2015 (edited) if (!file_exists("img/" . $_GET['remove'])) {echo "<script>console.log('Prelog');$(function() { $('#message_area').html('The file you try to remove does not exist.').fadeIn(500, function() { setTimeout(function () { console.log('Log works'); window.open('?manage=true', '_self'); }, 2000); });});</script>";} Fixed, forgot there is small script on footer.php that messed up my code. Feel like idiot now T_T Edited January 30, 2015 by Mudsaf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now