Search code examples
jqueryjquery-load

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>

Solution

  • 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