Solved

moving javascript to file causes error

Posted on 2015-01-23
4
148 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

695 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