why would my javascript file not be loading?
I am trying to load a JS file into my website, I have placed the file into exactly the same folder as one that does load, but firebug does not show that it has loaded, and it's effects are not visible.
Why could this be?
Here is the code to load the script
<script src="<?php bloginfo('template_url'); ?>/page-customs/js/开发者_开发知识库QES_form_edits.js" type="text/javascript"></script>
<script src="<?php bloginfo('template_url'); ?>/page-customs/js/datepicker.js" type="text/javascript" charset="utf-8"></script>
The first is not being loaded, the second is.
Here is the script itself:
jQuery(document).ready(function($) {
$("fieldset#keyword p.instruction").html("Search for a name or description of an activity, venue (e.g. Link Center)
or other keywords (e .g. coach)");
});
Jquery is loading fine.
Firebug will not show a javascript file as loaded if the file will not run due to invalidation. Fix JS, fix problem.
Ensure that the file actually exists. If you "view source", from the browser, you can hilite then right-click and copy the URL of the script. Go back to the browser, open a new tab, and right-click->paste the URL into the address bar, press enter. Does the script load in the browser window? If not, check the capitalization and spelling.
You script tag looks correct, so check your underlying assumptions.
EDIT
OK, since the file exists, let's determine why it isn't loading. You mentioned having Firebug, open that and switch to the 'Net' panel. You should see a GET for the script in question, along with its status. Is the status 200? Click that row and check the headers, as well as the Response tab within the expanded row. What do you see there?
Can you provide an example URL where this is occurring?
You need to make sure you include
<script type="text/javascript" src="file.js"></script>
in your source
The problem could be anything from file permissions or a poorly formatted file. I would check either of those. Also, is there anything in the "Net" tab in firebug that looks like it's at least trying to download the file?
An invalid html can also cause js files not to load. In my case I had this html inside a <div>
in the main <body>
tag:-
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;">
All the content after this piece of code was not recognized properly by the browser.
In my case, I did some changes which were not rendering correctly. So, I would recommend you to undo the changes that you have done (if any) and try.
精彩评论