Solved

jQuery in Visual Studio 2010 not working

Posted on 2011-02-11
8
744 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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: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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

734 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