Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 9th, 2010, 02:35 AM
Registered User
 
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default jQuery | Basic Question

Can't understand why jQuery library is not responding. My website is hosted locally on a Unix server w/ Cpanel. Tried creating the "jquery_test.js" file in both TextWrangler and Dreamweaver. Tried using both single ('*') and double ("*") quotes in <head> content, for example <script type='text/javascript', etc. Cpanel file manager confirms all necessary files are on the server. Is it possible that my (hosting) server httpd.conf needs to be set up differently for jQuery library to function properly? This is Example 1-1 from Wrox "beginning javascript and css development with jQuery. I even downloaded both the HTML and CSS source code example(s) and copied them to my (hosting) server. Still, jQuery is not loaded. Ridiculously frustrated! Please help!

Installed jQuery Library Path: /scripts/lib/jquery/jquery_132.js

Javascript File Path: /scripts/run/jquery/jquery_test.js

CSS File Path: /css/jquery.css

HTML DOC (jquery_test.html)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Untitled Document</title>
<script type='text/javascript' src='/script/lib/jquery/jquery_v132.js'></script>
<script type='text/javascript' src='/script/run/jquery/jqtest.js'></script>
<link href='/css/jquery.css' rel='stylesheet' type='text/css' />
</head>

<body>
<p>jQuery is not loaded</p>
</body>
</html>


JAVASCRIPT DOC (jquery_test.js)

if ($) {
$(document).ready(
function() {
$('p').addClass('tmpFrameworkLoaded');
$('p').text('jQuery successfully loaded and running');
}
);
}

CSS DOC (jquery.css)

@charset "UTF-8";
p {
font-family: Arial, Helvetica, sans-serif;
color: red;
display: block;
margin: 5px;
padding: 5px;
border: 1px solid red;
}
p.tmpFrameworkLoaded {
color: green;
border: 1px solid green;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
}
  #2 (permalink)  
Old January 9th, 2010, 06:34 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Code:
<script type='text/javascript' src='/script/run/jquery/jqtest.js'></script>
I don't see you include jquery_test.js anywhere....



Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old January 9th, 2010, 07:41 AM
Registered User
 
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default jQuery Question | Author Reply

Thanks for the reply! Paths to both my javascript doc and jQuery library, along with the CSS doc are shown below. Still won't load/run jQuery. What the heck am I missing???

HTML (jquery_test.html)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test | jQuery</title>
<script type="text/javascript" src="/script/src/jquery/jquery_v132.js"></script>
<script type="text/javascript" src="/script/run/jquery/jquery_test.js"></script>
<link href="/css/gestalt/site/jquery_test.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p>jQuery is not loaded</p>
</body>
</html>
JAVASCRIPT
Code:
if ($)
	$(document).ready
		function() {
			$('p').addClass('tmpFrameworkLoaded');
			$('p').text('jQuery is loaded and running');
		}
	);
}
CSS
Code:
@charset "UTF-8";
/* CSS Document */

p {
	padding: 5px;
	border: 1px solid #990000;
	color: #990000;
}
p.tmpFrameworkLoaded {
	color:	#006600;
	border:	1px solid # green;
}
  #4 (permalink)  
Old January 9th, 2010, 08:41 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

A few things you can check / do:

1. Put an alert statement (and nothing else) in your JS files. Does it get called?

2. Use Fiddler (www.fiddlertool.com) to see if any files are missing

3, Move all your code (JS and CSS) to your test HTML file and remove the file references. This way you can determine if it's a code issue or a file dependency issue.

4. Check your code as it doesn't look right to me. You're at least missing the opening { for the if statement and you're missing the parentheses for the ready function. Take a look at the code that comes with the book for a complete example.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please HELP Very Basic Question jkoe578 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 18th, 2006 10:06 AM
xslt basic question kgoldvas XSLT 2 January 25th, 2006 02:48 PM
basic xslt Question abhishek verma XSLT 4 January 24th, 2006 05:35 AM
basic question but..... Adam H-W Javascript How-To 2 February 10th, 2004 01:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.