title: Uncaught ReferenceError: getWidget is not defined
body: <p>I'm trying to call a function in <strong>index.php</strong> but I get this error <code>Uncaught ReferenceError: getWidget is not defined</code>. When I call the function in the <strong>widget.php</strong> it works. How can I get the function <strong>getWidget();</strong> to work in <strong>index.php</strong>?</p>
  
  <p>I also get this warning in <strong>index.php</strong></p>
  
  <pre><code>Resource interpreted as Script but transferred with MIME type text/html: "http://localhost/widget.php". 
  </code></pre>
  
  <p>and this error in <strong>widget.php</strong></p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token &lt; 
  </code></pre>
  
  <hr>
  
  <p>Here is index.php and widget.php</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;script type='text/javascript' src='widget.php'&gt;&lt;/script&gt;
  
  &lt;a href="#" onclick="getWidget();"&gt;Launch Widget&lt;/a&gt;
  </code></pre>
  
  <p><strong>widget.php</strong></p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="/scripts/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
  &lt;link href="/css/bootstrap/css/bootstrap.css" rel="stylesheet"&gt;
  &lt;script type='text/javascript' src='/css/bootstrap/js/bootstrap.min.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src='/css/bootstrap/js/bootstrap-transition.js'&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;script type="text/javascript"&gt;
    var http = getHTTPObject();
  
      function doauth() {
          setTimeout("doauth();", 15000);
          iframe = document.createElement('iframe');  
          iframe.id = "hiddenDownloader";
          iframe.style.visibility = 'hidden';
          iframe.src = "api.php";
          http.open("GET", "api.php");
          document.body.appendChild(iframe);
          http.onreadystatechange = handleHttpResponse;
          http.send(null);
      }
  
      function handleHttpResponse() {
          if (http.readyState == 4) {
        if (http.responseText != '') {
          rslt = http.responseText;
          document.getElementById('gw_content').innerHTML = rslt;
          first_time = '';
              }
              // http.onreadystatechange = function(){};
        // http.abort();
          }
      }
  
      function getHTTPObject() {
          var xmlhttp;
          /*@cc_on
          @if (@_jscript_version &gt;= 5)
              try {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) {
                  try {
                      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (E) {
                      xmlhttp = false;
                  }
              }
          @else
          xmlhttp = false;
          @end @*/
          if (!xmlhttp &amp;&amp; typeof XMLHttpRequest != 'undefined') {
              try {
                  xmlhttp = new XMLHttpRequest();
              } catch (e) {
                  xmlhttp = false;
              }
          }
          return xmlhttp;
      }
  
      function getWidget() {
          $('#myModal').modal('show');
      }   
  &lt;/script&gt;
  
  &lt;div class="modal hide fade" id="myModal"&gt;
    &lt;div class="modal-header"&gt;
      &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
      &lt;b style="color: #000;"&gt;Modal&lt;/b&gt;
    &lt;/div&gt;
      &lt;div class="modal-body"&gt;
          &lt;h4&gt;Modal&lt;/h4&gt;
              &lt;p&gt;Instructions...&lt;/p&gt;&lt;br /&gt;
                  &lt;div id="gw_content"&gt;
                      &lt;body onload="doauth();" /&gt;
                      &lt;img src="wheel-throb.gif"&gt;
                  &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;button type="button" onclick="getWidget();"&gt;Open&lt;/button&gt;
  </code></pre>