Solved

jQuery in Visual Studio 2010 not working

Posted on 2011-02-11
8
728 Views
Last Modified: 2012-05-11
Greetings, experts.

I am new to jQuery and decided to take the plunge.  I use Visual Studio 2010 ASP.NET for web development.

I downloaded the newest version of jQuery, 1.5, and added the file to the project.  I also found a version of the -vsdoc for 1.5 and added it in the same way.  The jQuery Intellisense seems to work fine.

After following all the steps for the typical "Hello World" test, nothing happens.

What have I missed?
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Text-jQuery.aspx.vb" Inherits="Text_jQuery" %>

<!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 runat="server">
    <title></title>

    <script src="scripts/jquery-1.5.min.js" type="text/javascript"></script>
    <script src="scripts/jquery-1.5-vsdoc.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("a").click(function () {
                alert("Hello World!");
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <a href="#">Click Here</a>
    </div>
    </form>
</body>
</html>

Open in new window

0
Comment
Question by:ewolsing
  • 4
  • 4
8 Comments
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 34872588
Mmm... if you add the attribute language="javascript"?
0
 

Author Comment

by:ewolsing
ID: 34872617
jorge toriz:

I added, language="javascript", to the script tag containing the Hello World jQuery code, but to no avail.
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 34872857
<script src="scripts/jquery-1.5.min.js" type="text/javascript" language="javascript"></script>
<script src="scripts/jquery-1.5-vsdoc.js" type="text/javascript" language="javascript"></script>

Mmm... can you post the HTML result of your execution?
0
 

Author Comment

by:ewolsing
ID: 34873047
I added, language="javascript", to the tags defining the location of the jQuery libraries.

I executed the page and clicked the link, but still did not receive the expected alert box.

Per request, the HTML received *after* I clicked the link is included.  I hope it helps.  I've been scratching my head on this for the last several hours.  From everything I've read, it should work.
<!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><title>

</title>

    <script src="scripts/jquery-1.5.min.js" type="text/javascript" language="javascript"></script>
    <script src="scripts/jquery-1.5-vsdoc.js" type="text/javascript" language="javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("a").click(function () {
                alert("Hello World!");
            });
        });
    </script>

</head>
<body>
    <form name="form1" method="post" action="Text-jQuery.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZEuZOv2bq3N7hsYmQUVPH9OqZ1C3xiqDh1uS1F+Iy7wd" />
</div>

    <div>
        <a href="#">Click Here</a>
    </div>
    </form>

</body>
</html>

Open in new window

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:jorge_toriz
ID: 34873215
When you run your test, there must be a ASP .NET Development Server... as an example, is suppose that is "http://localhost:12345/YouTest/Default.aspx"

If you visit "http://localhost:12345/YourTest/scripts/jquery-1.5.min.js" and "http://localhost:12345/YourTest/scripts/jquery-1.5-vsdoc.js"... do you get the scripts?
0
 

Author Comment

by:ewolsing
ID: 34873645
I checked that the directories in which the scripts are located are available to ASP.NET.  As you suggeseted, I attempted to access the jQuery libraries from the address bar of my browser and did so successfully.  When I entered the address, the jQuery library I selected displayed with no problem.

That suggests it's not an ASP.NET directory access issue.
0
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 250 total points
ID: 34873957
I have created an HTML page with the code that you posted, but I don't have the vsdoc file, so I didn't put that reference... if you remove that reference still not working?
0
 

Author Comment

by:ewolsing
ID: 34874078
Wow!  I commented out the vsdoc reference and it worked!

I suppose my next question is how I can retain the intellisense functionality without having to repeatedly comment and un-comment the vsdoc reference?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now