Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

First Ajax jQuery example

Ive been trying to get my first ajax jQuery code working and about to give up. I cannot figure out what it wrong, and it doesnt seem to be pussing any errors.

The code I think is quite simple, that is pull in the file test.html and stick the contents into the div with the ID 'result', however it doenst ever seem to fire.

<head>
    <title></title>
    <script type="text/javascript" src="..\jquery-1.6.4.js"></script>

    <script type="text/javascript">
        $(".trigger").click(function() {
            $.ajax({
                type: 'GET',
                url: 'test.htm',
                dataType: 'html',
                sucess: function(html, textStatus) {
                    $(".result").append(html);
                    },
                error: function (xhr, textStatus, errorThrown) {
                    $(".error").append(errorThrown ? errorThrown : xhr.status);
                    }
                })
            });
    </script>
</head>
<body>
<div id="trigger">Trigger</div>
<div id="result"></div>
<div id="error"></div>
</body>
</html>

Open in new window



Any ideas what Im doing wrong :-S
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tonelm54
tonelm54

ASKER

Ok, so spelling mistakes corrected, and # replaced with ', but still doesnt work :-(

<head>
    <title></title>
    <script type="text/javascript" src="..\jquery-1.6.4.js"></script>

    <script type="text/javascript">
        $("#trigger").click(function() {
            $.ajax({
                type: 'GET',
                url: 'test.htm',
                dataType: 'html',
                success: function(html, textStatus) {
                    $("#result").append(html);
                    },
                error: function (xhr, textStatus, errorThrown) {
                    $("#error").append(errorThrown ? errorThrown : xhr.status);
                    }
                })
            });
    </script>
</head>
<body>
<div id="trigger">Trigger</div>
<div id="result"></div>
<div id="error"></div>
</body>
</html>

Open in new window


Any ideas?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent, thank you for you help :-)