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

  • SEARCH
  • Home
  • 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 8507347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:50:46+00:00 2026-06-11T02:50:46+00:00

This is more than likely a very simple question. I have an external javascript

  • 0

This is more than likely a very simple question.

I have an external javascript file linked to my main html file. The link is good, but the functions won’t run when called. I know for a fact that the function works because I can copy and paste it into my main html file. However, the instant it is in an external file, the function won’t run.

What am I doing wrong?

Snippet of my main html file:

<html>

<head>
    <link rel="stylesheet" href="style.css">
    <script type="text/javascript" src="VRC_Index_Ajax_Functions.js"></script><--The issue file-->
    <script type="text/javascript" src="validations.js"></script> <--This file works-->

This is my entire VRC_Index_Ajax_Functions.js file. The function I’m dealing with mainly is showHint(str). I will mention that the showHint_l(str) doesn’t work within this file either. I’m not sure about the other functions yet.

 //VRC_Index_Ajax_Function.js - ajax calls


//Publisher Hints - First Name
function showHint(str)
{
 if (str.length==0)
 {
   document.getElementById("txtHint").innerHTML="";
   return;
 }
 if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
 }
 else
 {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
 xmlhttp.onreadystatechange=function()
 {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
 {
   document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
 }
 }
 xmlhttp.open("GET","gethint.php?q="+str,true);
 xmlhttp.send();
}

//Publisher Hints - Last Name
function showHint_l(str)
{
 if (str.length==0)
{
 document.getElementById("txtHint").innerHTML="";
 return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
 xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
   document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","gethint2.php?q="+str,true);
xmlhttp.send();
}

 //Ajax function for checking out territories - it will simply call the php file
 function checkOut(params)
{
var urlString = params;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
    document.getElementById("test").innerHTML=xmlhttp.responseText; 
}
//Setup for post submission 
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.open("POST","checkOut.php",true);
xmlhttp.send(urlString);
}



//Function that displays checked out territories
function displayChOut(params)
{
if(window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("displayCO").innerHTML=xmlhttp.responseText;
    }
}

xmlhttp.open("POST","ajax_checked_out.php",true);
xmlhttp.send();
 }

 function checkStatus()
 {
if(window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function()
{
    if(xmlhttp.readystate == 4 && xmlhttp.status == 200)
    {
    document.getElementsByName("numberOut").innerHTML=xmlhttp.responseText;
    }
}

xmlhttp.open("POST", "checkStatus_php.php", true);
xmlhttp.send();
 }

I really have no idea why it would suddenly not work in an external file. Any help would be appreciated.

  • 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-11T02:50:47+00:00Added an answer on June 11, 2026 at 2:50 am

    You missed a closing brace on a function:

    function showHint(str) {
        if (str.length === 0) {
            document.getElementById("txtHint").innerHTML = "";
            return;
        }
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "gethint.php?q=" + str, true);
        xmlhttp.send();
    }
    
    //Publisher Hints - Last Name
    function showHint_l(str) {
        if (str.length === 0) {
            document.getElementById("txtHint").innerHTML = "";
            return;
        }
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET", "gethint2.php?q=" + str, true);
        xmlhttp.send();
    }
    
    //Ajax function for checking out territories - it will simply call the php file
    function checkOut(params) {
        var urlString = params;
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("test").innerHTML = xmlhttp.responseText;
            }
            //Setup for post submission 
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.setRequestHeader("Content-length", params.length);
            xmlhttp.open("POST", "checkOut.php", true);
            xmlhttp.send(urlString);
        }
    } // Here
    
    
    
    //Function that displays checked out territories
    function displayChOut(params) {
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("displayCO").innerHTML = xmlhttp.responseText;
            }
        }
    
        xmlhttp.open("POST", "ajax_checked_out.php", true);
        xmlhttp.send();
    }
    
    function checkStatus() {
        if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {
                document.getElementsByName("numberOut").innerHTML = xmlhttp.responseText;
            }
        }
    
        xmlhttp.open("POST", "checkStatus_php.php", true);
        xmlhttp.send();
    }
    

    Not quite related to your question but a point of maintainability:

    xmlhttp is a global due to this code.

    It’s assigned to without being scoped.

    To make a variable local to a function scope do this:

    function somefunc() {
        var xmlhttp;
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright I know this is more than likely a amateur question but I have
I suppose this question is more general than working with COM components. I have
This is likely a very simple question with a straightforward answer but I'm something
This is a very simple question, and most likely requires a very simple answer.
This is more thinker than problem. I have a problem with thinking about how
I have been struggling with this error for more than two hours: error: aggregate
This question is more philosophical than technical. I've trained myself as a web developer
This is related to my previous question More than 1 Left joins in MSAccess
This is primarily a question of possibilities more than instructions. I'm a programming consultant
This is likely a much broader SQL topic than Entity Framework, and I'm very

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.