1

I am using a form to allow file download and to store the number of downloads but now I can't seem to find a way to fadeIn a subscribe div (#cover) on form success..

This is my form:

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="free-download" id="free-download">
    <button class="download" type="submit" name="clicks" onclick="window.open('download/imagins_._ro_free_files_format_icons.rar')">download (<span class="small"><?php echo getClickCount(); ?> times</span>)</button>
</form>

Is there a jquery way of doing this?

This is what I tried:

$("#free-download").bind('ajax:complete', function() {
          $('#cover').fadeIn(600);
          $('body').addClass('hidescroll');
});

Update

By changing the form action to <?php echo $_SERVER['PHP_SELF']; ?> and adding the following (below) I managed to add an echo to the page on form success, but how do I have the #cover div fadeIn?

<?php
if(isset($_POST['clicks'])) 
{ 
    echo "<p class='section-desc'>You just downloaded it</p>";
}
?>
3
  • You're missing the echo in the action attribute of your <form> tag but this is not the problem here. Just pointing out. Commented Mar 28, 2015 at 17:41
  • @D4V1D, adding <?php echo $_SERVER['PHP_SELF']; ?> isn't changing anything, is there something that I'm missing? Commented Mar 28, 2015 at 17:46
  • @D4V1D I found a way to do this, I answered my own question, check it out. Commented Mar 28, 2015 at 18:16

1 Answer 1

1

Working solution

Use php to echo a script tag containing whatever you want to achieve on submit success (in my case, a div fadeIn).

<?php
if(isset($_POST['clicks'])) 
{ 
    echo '
    <script type="text/javascript"> 
    $(function() {
        $( "#cover").fadeIn();
    });
    </script>';
}
?>
Sign up to request clarification or add additional context in comments.

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.