Solved

moving javascript to file causes error

Posted on 2015-01-23
4
144 Views
Last Modified: 2015-01-23
I have some javascript included in my html head and I think it runs on the page load. It is something like
$(function() {
;
;
});

if I move it to a file and then call it with:
<script type="text/javascript" src="/scripts/capture.js"></script>
it reports an error. How do I format the function if I move it to a file?
0
Comment
Question by:Gary Samuels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:10023
ID: 40567163
You broke the link to the     /scripts/capture.js   file when you move the the html file that includes the path in  the head script
0
 

Author Comment

by:Gary Samuels
ID: 40567181
I cut the javascript from the html header and pasted it into a file. Now in the header I'm calling <script type="text/javascript" src="/scripts/capture.js"></script> which is good because there is also a <base href="http://www.mydomain.com" />.
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40567411
Not much to go on. Is the error because of the doc ready function you posted or is it coming from deep inside the script?

Here's a dumb question. Does this markup, <script type="text/javascript" src="/scripts/capture.js"></script>, occur on the page AFTER your jQuery library include? If not, that would cause an error.
0
 

Author Closing Comment

by:Gary Samuels
ID: 40567571
Not a dumb question at all. YES, I placed the call before loading the JQuery library. So I guess I get the dummy award today.
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question