user1525227
user1525227

Reputation:

JQuery not working in ASP.NET

For some reason i can't seem to het jQuery to work in my asp.net page

I have sourced the jQuery library but the document.ready function never fires

i have also tried the window.load function as

    <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Page</title>
<script src="script/jquery-1.7.2.js" type="text/javascript" />

<script type="text/javascript">

    $(document).ready(function () {
        alert('works');
    });
</script>
</head>
<body">

    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    </div>
    </form>
</body>
</html>

Thanks

Upvotes: 1

Views: 4480

Answers (4)

ryuusenshi
ryuusenshi

Reputation: 1986

Maybe you didn't set up the script path correctly. To check that I would try importing Google hosted jQuery first.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

and also you really need to explicitly close the </script> tag

Upvotes: 1

Waqar Janjua
Waqar Janjua

Reputation: 6123

Once I have the same problem but when I use google ajax api it works for me. Try it

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" />

Upvotes: 1

Suave Nti
Suave Nti

Reputation: 3757

Script tags should be closed like this:

 <script src="script/jquery-1.7.2.js" type="text/javascript"></script>

Upvotes: 6

kerzek
kerzek

Reputation: 510

There is a " in the <body"> tag

Upvotes: 8

Related Questions