Jump to content

jQuery wont execute script on $(function)


Mudsaf

Recommended Posts

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 by Mudsaf
Link to comment
Share on other sites

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 by Mudsaf
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...