0

I have a page where i want to send exclusive music releases to big djs/radios ...etc.

The main function is:

They need to leave feedback about the musics, then they can download the tracks!

I had goes trough a plenty of sites for the answer but i haven't found any useful tips!

Here is the post by ajax:

  <script>
$(document).ready(function(){
    $('#submit').click(function() {
        $.ajax({ 
            type: "POST",
            url: "send.php",
            data: $("#feedbackpanel").serialize(),
            success: function(data){
                       $("#download-button").removeAttr('disabled');            
            }
        }); 
    });
    return false; 
});
</script>

Here is the form:

<form id="feedbackpanel">
<br/>
    Artist/Producer Name:<br/><br/> <input type="text" name="name" pattern=".{3,}" placeholder="Let us know who you are! :)"  style="width:150px" title="Thats your name? :)" onFocus="if(!this._haschanged){this.value=''};this._haschanged=true;"  /><br/><br/>

    Leave your feedback here: <br/> <br/>
    <input title="Please 10 character at least!" type="text" name="feedback"  pattern=".{10,}"  placeholder="At least 10 character..."  onFocus="if(!this._haschanged){this.value=''};this._haschanged=true;"  style="height: 50px; width:300px"/><br/><br/>

<input type="submit" id="submit" name="submit" value="Submit" style="font-size: 14px; color: white; border:1px solid transparent" />

<input type="button" id="download-button" value="download" onclick="location.href='filedestination/filename.zip';"  disabled="disabled" />

</form>

Whats is the problem?

Please help to me!

Thanks!

Roland
  • 5
  • 2
  • 1
    What happens if you change "sucess" to "complete" ? – Felipe Skinner Sep 11 '13 at 16:54
  • 1
    Is the success function called? You should probably check if the server is returning an error. – David Sep 11 '13 at 16:55
  • Possible solution here: http://stackoverflow.com/questions/4138950/jquery-removeattrdisabled-not-working-on-firefox – Chris Rasco Sep 11 '13 at 16:57
  • Is setting the `button` to disabled the only way that you're preventing people from being able to download the music? That's easily hackable. – MattDiamant Sep 11 '13 at 16:59
  • the "complete" is not working too. success function called right, i'm giving the post into database. that solution not working too! Matt, do you have better option? i'm waiting that too! :) – Roland Sep 11 '13 at 18:44

1 Answers1

3

You're submitting the form and seeing a fresh copy of the page, instead of making an AJAX call.

Either: use a "regular" button, not type="submit"

or: capture the event in your function and use event.preventDefault();

 $('#submit').click(function(event) {
    event.preventDefault();
    ...your existing code...
Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176