Jump to content

Javascript not working to load message


GhostElite_89

Recommended Posts

So i have the following code in a main page and it works perfectly:

	<script src="assets/js/demo.js"></script>

	<script type="text/javascript">
    	$(document).ready(function(){

        	demo.initChartist();
				var username = "<?php echo $user; ?>";
        	$.notify({
            	icon: 'pe-7s-gift',
				
				
				
            	message: "Welcome to VendorBase Pro, <b>" + username + "</b>! New updates will be coming soon!"				
            },{
                type: 'info',
                timer: 4000
            });

    	});
	</script>

and I moved it and modified it to another page where, on click (php), it loads a database and executes. I've tested it with just firing off an alert message and it works flawlessly. I'm lost at where my error is.

	<script src="assets/js/demo.js"></script>
	<script type="text/javascript">
    	 function added(){

				demo.initChartist();
					var username = "test";
				$.notify({
					icon: 'pe-7s-gift',
					
					
					
					message: "Welcome to VendorBase Pro, <b>" + username + "</b>! New updates will be coming soon!"				
				},{
					type: 'info',
					timer: 4000
				});

    	});
	</script>

This code is placed at the top of a PHP page and here's the command

echo '<script type="text/javascript">added();</script>';

 

Link to comment
Share on other sites

I fixed that mistake, but also changed my code to use Toastr. Now it does make it to the function (tested it with a generic alert("hello"); and it loaded but using the following does not work. Where did I go wrong?

 

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	 <script src="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.2/js/toastr.min.js">
	 
  <script type="text/javascript" src="assets/js/popper.min.js"></script>
  
  <script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
	<!--  Charts Plugin -->
	<script src="assets/js/chartist.min.js"></script>

    <!--  Notifications Plugin    -->
    <script src="assets/js/bootstrap-notify.js"></script>

    <!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
	<script src="assets/js/light-bootstrap-dashboard.js?v=1.4.0"></script>

	<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
	<script src="assets/js/demo.js"></script>
	



  <!-- MDB core JavaScript -->
  <script type="text/javascript" src="assets/js/mdb.min.js"></script>
<script type="text/javascript">

		 $(function () {
			$('#add').click(function () {
					toastr.info("Folder 2 has been clicked!" );

					});
});
	</script>

 

Link to comment
Share on other sites

I fixed the </script> missing but it's still not working.

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	 <script src="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.2/js/toastr.min.js"></script>
	 
  <script type="text/javascript" src="assets/js/popper.min.js"></script>
  
  <script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
	<!--  Charts Plugin -->
	<script src="assets/js/chartist.min.js"></script>

    <!--  Notifications Plugin    -->
    <script src="assets/js/bootstrap-notify.js"></script>

    <!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
	<script src="assets/js/light-bootstrap-dashboard.js?v=1.4.0"></script>

	<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
	<script src="assets/js/demo.js"></script>
	



  <!-- MDB core JavaScript -->
  <script type="text/javascript" src="assets/js/mdb.min.js"></script>
<script type="text/javascript">

		 $(function () {
			$('#add').click(function () {
					toastr.info("Folder 2 has been clicked!", "Folder 2", );

					});
});
	</script>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.