?
Solved

JQuery Code Not Working after NuGet Scripts Install?

Posted on 2012-08-15
7
Medium Priority
?
658 Views
Last Modified: 2012-08-16
I successfully ran JQuery code using this src string:

<script type="text/javascript" src="/bin/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
 $(document).ready(function () {
//jquery code
});
</script>

However, now after installing the scripts via NuGet (nuget.org) I cannot run JQuery script and I don't recieve any runtime errors either.

Also tried removing the second script tag (bold below) and still nothing. Notice the new directory is 'scripts' instead of 'bin'. Other than that the .js file is the same.

<script type="text/javascript" src="/scripts/jquery-1.8.0.min.js"></script>
<script type="text/javascript"> $(document).ready(function () {
//jquery code
});
</script>


Help!
0
Comment
Question by:pointeman
7 Comments
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 38299147
Try this [just checking whether path is correct or not]..



<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
 $(document).ready(function () {
//jquery code
});
</script>
0
 
LVL 4

Expert Comment

by:Friman001
ID: 38299152
Yah, jquery is only at v1.7.*!

Ryan F
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 38299184
Friman001 : FYI, 1.8.0 is released
0
Industry Leaders: 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!

 

Author Comment

by:pointeman
ID: 38299875
Yes, it works with both 1.7.2 and 1.8.0 using the google URL you provide. The problem is using the same .js file in the local Scripts directory. I recently installed VS 2012 RC and loaded the same project I've been using in VS 2010. It works using the Scripts directory. I must note the Scripts does not work using VS 2008 either. I thought it could be a browser issue as well.

[Testing Results using Scripts folder]
VS 2008 / IE8 - not working
VS 2008 / IE9 - not working
VS 2010 / IE8 - not working
VS 2010 / IE9 - not tested
VS 2012 / IE9 - works!
0
 

Author Comment

by:pointeman
ID: 38299966
Also tried eliminating the second <script> tag and found the page load error is gone, but the JQuery code never runs either. Why doesn't the example allow the code to run?

<script type="text/javascript" src="/scripts/jquery-1.8.0.min.js">
      $(document).ready(function () {
           //jquery code
      });
</script>
0
 
LVL 45

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38301385
You need one script tag to load the jQuery library and one to run your jQuery code. You can't have them both in one script tag.

If this is for a website (as opposed to an internal intranet app) then best practice is to use a CDN for the library - i.e Google, rather than a local copy.

It sounds like you have a path/permissions problem relating to your server setup - this doesn't look like a jQuery issue so asking the question in a different zone may get you better results.

Good luck with it.
0
 

Author Closing Comment

by:pointeman
ID: 38302975
Yes, the issue seems be our version software MKS. It doesn't play nice with JQuery script directory. thx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

830 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