I am animation a box, and asynchronously changing its text that's coming in from another file. When I click on it, the box animates (grows and changes color), and call in the other text. But the box should shrink and put the original content back with clicked again, or when the close anchor link is clicked, I don't care which works. This doesn't happen, the box only animates, and I am not sure why.
My guess is that since the anchor 'close' link is inside the '#effect div' that's to be clicked on to replace the original text, it keeps calling the first $ajax() function that replaces the original text. I dont know what would make this work the way I want though.
Also, I know that success() is going to be deprecated soon, but when i replacing it with done, the ajax doesn't work. Not sure why.
Code:
//open source file
$( "#effect" ).click(function() { //when this div is clicked
$.ajax({
url: 'loadedContent.html', //take this url and..
success: function(data) { //if this is successful
$('#content').html(data); //put it in here
}
}); console.log("grow");
});
//close source file
$( "a" ).click(function() {
$.ajax({
url: 'originalContent.html',
success: function(data) {
$('#content').html(data);
}
}); console.log("shrink");
});
$( ".node" ).toggle(
//grow
function() {
$( ".node" ).animate({
backgroundColor: "#636668",
color: "#fff",
width: 800,
fontSize: "15pt",
bottom: "-=100px",
}, 1000 );
},
//shrink
function() {
$( ".node" ).animate({
backgroundColor: "#C6CCD1",
color: "#000",
width: 240,
fontSize: "10pt",
bottom: "+=100px",
}, 1000 );
}
); // end toggle
});
</script>
</head>
<body>
<div class="demo">
<div class="toggler">
<div id="effect" class="node">
<div id="contentContainer">
<div id="content">
<h3>Quote:</h3>
<p>
<q>Etiam libero neque, luctus a, eleifend nec, semper at, lorem.<q>
</p>
</div></div>
</div>
</div>
</div><!-- End demo -->
</body>
</html>