title: echo jQuery function in PHP as variable
body: <p>Ok so I am trying to echo an function from jQuery inside of PHP.</p>
  
  <p>I was searching a little bit, I did not found any exact answer but I found that I need to use ajax for it ? </p>
  
  <p>I am not familiar with ajax so I have found this.</p>
  
  <pre><code>&lt;?php 
      $status = "&lt;script&gt;
                   $.ajax({ 
                      url: '/',
                      data: {action: 'test'},
                      type: 'post',
                      success: function(output) {
                         notifyBox();
                      }
                   });
                 &lt;/script&gt;";
  ?&gt;
  </code></pre>
  
  <p>I also have this part somewhere on the page:</p>
  
  <pre><code>&lt;?php if(isset($status)) { echo $status; } ?&gt;
  </code></pre>
  
  <p>I am not quite sure if I need all of that to execute the function ?
  But it works only if I put jQuery in head of the website.</p>
  
  <p>I usually put all my scripts above <code>&lt;/body&gt;</code> (at closing tag) and now it bothers me if I have to put all these scripts into head </p>
  
  <p>Because of many pages I cannot separate all scripts now just cause of one page that bother me at the moment.</p>
  
  <p>Can anyone please tell me, how do I call that function without getting console error of undefined '$' because jQuery is loaded at the end of the page.</p>
  
  <p>Thank you in advance.</p>