One thing to point out is the you don't need the "return false" in your
code. Because a DIV doesn't have a built in click handler (like an a tag
does) you don't need to cancel it's click handler. This should work just
fine:

$(document).ready(function() {
        $("//[EMAIL PROTECTED]//a").click( function() {
                $.get("myfile.htm", function(data){
                        $("#stand-summary").html(data)
                });
        });
});




-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of QuackFuzed
Sent: Monday, April 09, 2007 12:44 AM
To: jQuery (English)
Subject: [jQuery] jQuery n00b


Hello,

After reading lots about jQuery on a number of CF blogs/lists, I've finally
got a project that I think warrants me jumping into it.  I've only started
going through the docs, etc a few hours ago, so I'm sure I'm overlooking
something somewhere, but I have seen so many people brag about the wonderful
community that is jQuery, and figured I'd give it a whirl.

I am trying to create a simple ajax call.  I've tried a number of code
combinations, but the only version I can get to "work" (e.g. load the
file) is this:

$(document).ready(function() {
        $("//[EMAIL PROTECTED]//a").click(
                function() {
                        $("#stand-summary").load("myfile.htm")
                        return false
                }
        );
});

In theory, I could write a number of blocks like this - one for each page I
want to load - but that would pretty much defeat the purpose of using
jQuery.  So, there are two things that I'm trying to solve here:

1) Dynamically get at the href attribute's value, and
2) Figure out how to properly use the $.ajax() method

I have tried this code, which appears to be correct, based upon my obviously
limited knowledge of jQuery, but does not provide the desired result.  It
throws no errors in FireBug, but produces an empty string as the result...

$(document).ready(function() {
        $("//[EMAIL PROTECTED]//a").click(
                function() {
                        var stuff = $.ajax({
                           url: "myfile.htm"
                           }).responseText
                        $("#stand-summary").load(stuff)
                        return false
                }
        );
});

Any tips/pointers as to what I'm doing wrong would be tremendously
appreciated.


Thanks,

Matt


Reply via email to