title: Calling a JQuery UI Dialog function from PHP
body: <p>I am quite new to the JQuery language but I have found a tutorial on the net that helped me to get the dialog working from a click button.</p>
  
  <p>the function i use is as following:</p>
  
  <pre><code>$("#registration_ok").click(function() {
      $("#dialog").attr('title', 'Registration').text('Your Registration was Successfull!').dialog({ buttons: { 'Ok': function() {
          $(this).dialog('close');
      }}, open: function(){
              jQuery('.ui-widget-overlay').bind('click',function(){
                  jQuery('#dialog').dialog('close');
              })
          }, closeOnEscape: true, draggable: false, resizable: false, hide: 'fade', show: 'fade', modal: true, dialogClass: 'success'});
  });
  </code></pre>
  
  <p>I now want to use this function and call it from a php file, but i cant get it to work.
  I might need to rewrite the function since i think it will only respond on an actual click so i tried the following:</p>
  
  <pre><code>function dialog() {
      $("#dialog").attr('title', 'Registration').text('Your Registration was Successfull!').dialog({ buttons: { 'Ok': function() {
          $(this).dialog('close');
      }}, open: function(){
              jQuery('.ui-widget-overlay').bind('click',function(){
                  jQuery('#dialog').dialog('close');
              })
          }, closeOnEscape: true, draggable: false, resizable: false, hide: 'fade', show: 'fade', modal: true, dialogClass: 'success'});
  };
  </code></pre>
  
  <p>I have tried to call the function in different ways, but none did work:</p>
  
  <pre><code>if(isset($_GET['success'])) { echo '&lt;script type="text/javascript"&gt; function() { dialog(); } &lt;/script&gt;'; }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>if(isset($_GET['success'])) { echo '&lt;script type="text/javascript"&gt; dialog();&lt;/script&gt;'; }
  </code></pre>
  
  <p>none did work, can anyone tell me what i am doing wrong?</p>