0

I'm trying to create a website with tabbed browsing and have followed a tutorial to make this. But the problem is that the code I'm currently is using doesent work as expected.

The tutorial I followed: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/

The problem: When I click one of the tabs the #content goes away with a slideUp and .load loads the content but it doesent place the content in #content.

4
  • Is your external file on the same webserver? Commented Jan 12, 2011 at 16:31
  • can you post your random1.html too? Commented Jan 12, 2011 at 17:53
  • @justkt, yes. The external file is being loaded if you check with Firebug. Commented Jan 13, 2011 at 14:43
  • @ifaour, random1.html contains "<h1>Hello</h1><p>Hello</p>" Commented Jan 13, 2011 at 14:44

2 Answers 2

2
  1. You have some duplicate #ids.
  2. Remember when you do:

    var toLoad = $(this).attr('href')+' #content';
    // other execution
    function loadContent() {
       $('#content').load(toLoad,function(){
       $('#content').slideDown('normal');
    });
    

you are actually loading a page fragment #content into #content in your page. So you end up with this:

<div id='content'>
   <div id='content'>Random Data</div>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

removed the "'+ #content'" and it all works now. Thanks alot!
0

Okay, based on your comment..Just make sure that you actually have a DIv with ID #content in your random html files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.