1

I currently have links w/ class="ajax" that I want to retrieve the element with id="test" from the file "data.html" in the same directory, and put that content into the id="content" div on my page:

<script>
$(document).ready(function(){
    $("a.ajax").click(function(event){
    $("#content").load("/data #test");
    });
});
</script>
<a class="ajax" href="#">Text</a>
<div id="content"></div>

and externally, but in the same directory, I have data.html:

<div id="test">Will this show up?</div>

On the clicking of the anchor, Safari reports "page loading interupted", and no change occurs.

I definitely have JQuery called in the header. Can I get some help with this function? Thanks!

2 Answers 2

1

You have /data but the file is /data.html, assuming you're in the root. :)

I just tested what you have with this change and it works fine for me. I also recommend you get a tool like Firebug so you can easily see what your AJAX requests are doing.

Sign up to request clarification or add additional context in comments.

1 Comment

Great help, thanks. It's so hard to not work in an environment where I can just lean over in my chair and say "Hey, what' wrong with this?". Stack Overflow is so useful!
0
$.ajax({
    url: "data.html",
    type: "POST",
    success: function (answer) {
        $("main_content").html($(answer).find("div#content_id").html());
    }
});

I hope it will help you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.