Boas Enkler
Boas Enkler

Reputation: 12557

jquery.Load works only within asp.net

I'm quite new to jQuery and can't find out what doesn't work.

Tn the following sample the code works fine when the page is part of a asp web application.

But when I create a normal Website in IIS the load doesn't work. The event raises (tried it with alert) but nothing is loaded.

I alays asumed that jScript ( jQuery ) is independent form host mechanisms. Am i wrong?

<!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>
    <script src="../../Scripts/jquery-1.5.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#MyButton').click(function () {
                //Load HTML from HelpDetails.html
                $('#OutputDiv').load('../HelpDetails.html #SubTOC');
            });
        });
    </script>
</head>
<body>
    <button id="MyButton">Click to Get HTML</button>
    <div id="OutputDiv"></div>
</body>
</html>

Upvotes: 0

Views: 175

Answers (4)

Bram Vanroy
Bram Vanroy

Reputation: 28447

Possible problems can be: jQuery is not loaded (but very unlikely if it works in some cases), html is not loaded. To exclude both: check the console in your browser. If you don't know why, please post which browser you are using. Also, it might be a better idea to link your jQuery to a library of another host (e.g. Google's)

Upvotes: 1

lucuma
lucuma

Reputation: 18339

Change the script line to this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Upvotes: 0

Shyju
Shyju

Reputation: 218732

What is firebug console saying ? The only reason i could think is a wrong (remote) file path. Make sure you have a file called HelpDetails.html in the location where jQuery load method is looking for. A 404 error ?

enter image description here

Upvotes: 1

Logard
Logard

Reputation: 1513

You could try using Server.MapPath("~/your-path-to-jquery") to get the path to your script, might be that it just cant be found.

Upvotes: 0

Related Questions