Mick Jack
Mick Jack

Reputation: 580

jquery function after button is click?

i have this auto-refresh script using jquery. i want the function to run only after user had click the submit button. When user click the submit button ffmpeg will convert the video and progress.php will retrieve the estimated time taken while waiting for ffmpeg to complete converting the video.

html form

<form action="upload.php" method="post" enctype="multipart/form-data">
  <label for="file"><span></span></label>
   <input type="file" name="file" id="videofile" />
  <br/> Please enter video title:
  <br/>
  <input type="text" name="videoTitle" id="videoTitle" onkeyup="check()" />
  <br />
  <input type="Submit" id="Submit" value="Upload" disabled />
</form>

so far i had tried this code but its not working..

$("#submit").submit(function(event){
$("#submit").click(function(event){
$(document).ready(function(){

Jquery

//$(document).ready(function(){
    $("#submit").click(function(event){
        setInterval(function(){
            $("#myDiv").load('progress.php')
        }, 2000);
    });

Upvotes: 0

Views: 1041

Answers (2)

Amar Singh
Amar Singh

Reputation: 5622

First of all your button id is Submit and not submit change that and check if it works

Further if you want to run a code before submit than you can do following :

use input type= button

and onclick of that run a function within that function submit the form

For eg :

$('#button_id').click(function(e){
    e.preventDefault();
    //do whatever and submit
    $("#Form_id").submit();
});

Upvotes: 1

Patoliya Nitin
Patoliya Nitin

Reputation: 70

$('#submit').click(function() {
    location.reload();
});

Please use this code for on click event refresh page.

Upvotes: 0

Related Questions