Jump to content

How come some javascript files won't work externally?


man5

Recommended Posts

Say on an Html page, I have a a js file like this.

<html>
<head>
       <script type="text/javascript" src="fileName.js"></script>
</head>
</html>

Well it's an ajax file to be exact.  The problem with above is that the code won't run from the file path.  If I put the code right on the html page below, it'll work.  Doing it like this is very messy if I have many scripts running.

<html>
<head>
       <script type="text/javascript" src="fileName.js">
           ajax code here...
       </script>
</head>
</html>

Can anyone tell me what the problem is exactly?

 

 

 

And no, this is not an issue with all js files.  I suppose it's only the ones with ajax running.

Link to comment
Share on other sites

What do you mean by "not working"? Are you getting any errors? Have you run your code while your browser's developer tools are running?

 

And you should show your code (within our forum's code tags (the <> button in our text editor or by manually typing


and placing your code within)).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.