Solved

moving javascript to file causes error

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Asp in server side with Mssql Server 7 4 28
Selected in an option list 13 21
Search Item in Table 2 23
send email part1 9 28
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

828 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