0

I'm not sure if this is actually possible but I would have thought it is. I am very new to jquery. What I am trying to do is nest two functions.

Hide the target div load the new page into the div open up the div again

This works if I place the initial slideToggle on its own but I want to make sure the page is loaded before opening again

function nickyLoad(siteToFetch,whereToPut){
$('#'+whereToPut+'').slideToggle('slow', function() {// collapse target
    $('#'+whereToPut+'').load(siteToFetch, function() { //load new site
        $('#'+whereToPut+'').slideToggle('slow','');
    });
)};

}

Many thanks!

5
  • 1
    I don't see anything seriously wrong with that; what is the problem? Commented Jul 3, 2010 at 20:04
  • 3
    Does it make your computer explode? Does it give you head lice? Does it turn the screen all black suddenly? Commented Jul 3, 2010 at 21:36
  • @Pointy I hate it when I get lice :( Commented Jul 3, 2010 at 22:25
  • Its javascript... thus it results in none of the scripts working... Could it be that I cant use slideToggle within slideToggle? Commented Jul 4, 2010 at 8:27
  • @Pointy: Javascript fails silently. Commented Jul 4, 2010 at 17:07

1 Answer 1

1

You've mixed up the order of } and ) when closing the first slideToggle call (you've written )}; instead of });

function nickyLoad(siteToFetch,whereToPut){
    $('#'+whereToPut+'').slideToggle('slow', function() {// collapse target
            $('#'+whereToPut+'').load(siteToFetch, function() { //load new site
                    $('#'+whereToPut+'').slideToggle('slow','');
            });
    }); //<-- corrected
}

These things (syntax errors) are easy to find with some simple tools. In firefox you can open the error console (Tools --> Error Console) and go to the "Error" tab. In Internet Explorer use the Developer Tools (Tools --> Developer Tools) and go to the "Script" tab.

Firebug for firefox is also highly recommended.

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

1 Comment

Thanks. Ended up using a different script now :) will have a look at firebug!

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.