robs99 Posted August 24, 2010 Share Posted August 24, 2010 Hey, im trying to load new content through ajax in a div and instead of showing all the new content at once i want the div to slowly slide down and reveal the new content. For some reason its not working, the new content gets loaded and its shown at once. Here is a demo: http://gator1016.hostgator.com/~youtubed/test/ And here is the JS code: function loadnew() { $('#divcontent').html('<img src="ajaxbar.gif">'); $.ajax({ url: 'ajaxcontent.php', success: function(data){ $('#divcontent').html(data); $('#divcontent').slideDown('slow'); } }); } Any ideas? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/211597-jquery-slidedown-after-ajax-not-working/ Share on other sites More sharing options...
Adam Posted August 24, 2010 Share Posted August 24, 2010 Strangely it works if the div is set to display:none. What you could do as a bit of a work around is wrap the response data in a hidden div and apply the .slideDown() to that? Link to comment https://forums.phpfreaks.com/topic/211597-jquery-slidedown-after-ajax-not-working/#findComment-1103130 Share on other sites More sharing options...
AtlasC1 Posted August 24, 2010 Share Posted August 24, 2010 Yeah, the container of the data in jQuery has to be set to display:none; if you want it to start out in a manner that isn't visible, then have it slide down. -jm Link to comment https://forums.phpfreaks.com/topic/211597-jquery-slidedown-after-ajax-not-working/#findComment-1103155 Share on other sites More sharing options...
robs99 Posted August 24, 2010 Author Share Posted August 24, 2010 hello, thanks for the replies. the thing is i dont want to hide the div before it loads, i just want it to scroll to the "new" height of the loaded content. i know it works if i scroll it up, load the content and then scroll it down. but i want to find a way to do this without having to hide or scroll the div up. its hard to explain what im trying to achieve, i hope you understand what i mean thanks in advance Link to comment https://forums.phpfreaks.com/topic/211597-jquery-slidedown-after-ajax-not-working/#findComment-1103297 Share on other sites More sharing options...
Adam Posted August 25, 2010 Share Posted August 25, 2010 I posted a solution above; I've tested it with your code and it works. Link to comment https://forums.phpfreaks.com/topic/211597-jquery-slidedown-after-ajax-not-working/#findComment-1103587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.