When you use a callback, you don't include the parenthesis, only the
function variable:

fadeIn(1500, animateResults());
is incorrect. Use:
fadeIn(1500, animateResults);

On Feb 21, 11:12 pm, 123gotoandplay <wesweatyous...@gmail.com> wrote:
> Hi all,
>
> i am trying to animate poll bars after/during a fadein
>
> I have a animateResults function, handlePoll function. I have checked
> animateResults() and it works when i am not using it in an ajax
> structure
>
> ----------
> function handlePoll() {
>         $('.error').hide();
>         $(".voteBtn").click(function() {
>                 var poll = $("input[name=poll]:checked").val();
>                 //alert("send selected: "+poll);
>                         if (poll == 'undefined') {
>                                 alert("don't post");
>                                 $("label#poll_error").show();
>                                 return false;
>                           }
>
>                 var question_id = $("#question_id").val();
>                 var t =  $("#t").val();
>
>                 var dataString = 'poll=' + poll +'&question_id='+question_id
> +'&t='+t;
>
>                  $.ajax({
>                         type: "POST",
>                         url: "/bezoekers/poll-process5.php",
>                         data: dataString,
>                         success: function(msg) {
>                         //alert(msg);
>                                 $("#poll-container").html("<div 
> id='poll-results'></div>");
>                                 $("#poll-results").html(msg)
>                                         .hide()
>                                         .fadeIn(1500); //.fadeIn(1500, 
> animateResults());
>                         }
>                   })
>                  return false;
>         });
>
> }
>
> function animateResults(){
>                 //alert("animate");
>           $("#poll-results div").each(function(){
>                   var percentage = $(this).next().text();
>                   $(this).css({width: "0%"}).animate({width: percentage}, 
> 'slow');
>           });
>
> }//end animateResults
>
> $(document).ready(function(){
>
>         handlePoll();
>
>         if ($("#poll-results").length > 0 ) {
>                         animateResults();
>                 }
>
> });

Reply via email to