• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

JQuery Code Not Working after NuGet Scripts Install?

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
pointeman
Asked:
pointeman
1 Solution
 
Kiran SonawaneProject LeadCommented:
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
 
Friman001Commented:
Yah, jquery is only at v1.7.*!

Ryan F
0
 
Kiran SonawaneProject LeadCommented:
Friman001 : FYI, 1.8.0 is released
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
pointemanAuthor Commented:
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
 
pointemanAuthor Commented:
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
 
Chris StanyonCommented:
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
 
pointemanAuthor Commented:
Yes, the issue seems be our version software MKS. It doesn't play nice with JQuery script directory. thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now