Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:01:31+00:00 2026-06-17T23:01:31+00:00

I’m trying to call a function in index.php but I get this error Uncaught

  • 0

I’m trying to call a function in index.php but I get this error Uncaught ReferenceError: getWidget is not defined. When I call the function in the widget.php it works. How can I get the function getWidget(); to work in index.php?

I also get this warning in index.php

Resource interpreted as Script but transferred with MIME type text/html: "http://localhost/widget.php". 

and this error in widget.php

Uncaught SyntaxError: Unexpected token < 

Here is index.php and widget.php

index.php

<script type='text/javascript' src='widget.php'></script>

<a href="#" onclick="getWidget();">Launch Widget</a>

widget.php

<!DOCTYPE HTML>
<head>
<script type="text/javascript" src="/scripts/jquery-1.7.1.min.js"></script>
<link href="/css/bootstrap/css/bootstrap.css" rel="stylesheet">
<script type='text/javascript' src='/css/bootstrap/js/bootstrap.min.js'></script>
<script type='text/javascript' src='/css/bootstrap/js/bootstrap-transition.js'></script>
</head>

<script type="text/javascript">
  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 >= 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 && typeof XMLHttpRequest != 'undefined') {
            try {
                xmlhttp = new XMLHttpRequest();
            } catch (e) {
                xmlhttp = false;
            }
        }
        return xmlhttp;
    }

    function getWidget() {
        $('#myModal').modal('show');
    }   
</script>

<div class="modal hide fade" id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <b style="color: #000;">Modal</b>
  </div>
    <div class="modal-body">
        <h4>Modal</h4>
            <p>Instructions...</p><br />
                <div id="gw_content">
                    <body onload="doauth();" />
                    <img src="wheel-throb.gif">
                </div>
        </div>
    </div>

    <button type="button" onclick="getWidget();">Open</button>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:01:33+00:00Added an answer on June 17, 2026 at 11:01 pm

    There are a few areas of concerns, such as linking a .php extension into a script src attribute, that’s causing one of your error message in index.php to appear.

    However, to resolve the issue of getWidget not being defined, I would remove the <script> block from widget.php into a separate .js file (ie, yourfile.js) and access it in your index.php file like so,

    <script type='text/javascript' src='yourfile.js'></script>
    <a href="#" onclick="getWidget();">Launch Widget</a>
    

    Also, within widget.php are there any PHP code inside that file? If not, then you should rename it to a .html or .htm extension for clarity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I need a function that will clean a strings' special characters. I do NOT
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.