title: Trigger a jQuery function from another file in JS
body: <p>How I can call/trigger a jQuery function (which is in another file) from JS.
  So basically this is the jQuery function (/js/animation.js).</p>
  
  <pre><code>$('#spin').click(function () {
      var tickets = Math.floor(Math.random() * 200) + 1;
      if(tickets &lt; 51) {  
      var winner = 155;
      }
      else {
      var winner = 145;   
      }
      rouletteSpin(winner);
  });
  </code></pre>
  
  <p>I know that its based on a codepen Roulette Animation.
  Now the problem is that it should not roll without going through an if statement.
  The statement should be a variable using Database info.
  That's the point.
  In my opinion you cant use PHP / select DB Info in jQuery so I decided to go into my index.php to trigger the jQuery function after the if statement in js went through.
  So let me show you my HTML Button + JS Function:</p>
  
  <pre><code> onclick="openCase()
  </code></pre>
  
  <p>into the first HTML Button tag.</p>
  
  <p>Now the JS Function:</p>
  
  <pre><code>    &lt;script&gt;    
      var credits = CodeToGet_MYSQL_DB_Info_here_written_in_php;
  
  
      function openCase() {
      if(credits &gt; 10000) {
       spinIt();
      }
      else {
          alert('Something went wrong');
      }
      }
  </code></pre>
  
  <p>And changed the jQuery Function (in path /js/animation.js) to the following:</p>
  
  <pre><code>function spinIt () {
      var tickets = Math.floor(Math.random() * 200) + 1;
      if(tickets &lt; 51) {  
      var winner = 155;
      }
      else {
      var winner = 145;   
      }
      rouletteSpin(winner);
  });
  </code></pre>
  
  <p>That is not working. I already googled a lot so please don't flame me.
  Already used pretty much every method of this post:</p>
  
  <p><a href="https://stackoverflow.com/questions/1345722/calling-jquery-function-from-javascript">calling Jquery function from javascript</a></p>
  
  <p>Would be nice if someone can help me out!</p>