0

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);
    });
10
  • as far as i know when form is submit it will automatically refresh the page. so use a form and button type submit and you are good to go Commented Feb 3, 2016 at 7:56
  • you can use event.preventDefault() to block form from submitting, if that is what you want. Commented Feb 3, 2016 at 7:57
  • @RejithRKrishnan i think he wants to reload the page after button click not prevent it Commented Feb 3, 2016 at 7:58
  • 2
    How is the user supposed to see any of this if they just submitted a form and are being redirected? Commented Feb 3, 2016 at 7:58
  • I think you have to submit your form via ajax and display the progress of the upload on the page. After the converting is done, you can than reload your page or redirect. Commented Feb 3, 2016 at 8:00

2 Answers 2

1

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();
});
Sign up to request clarification or add additional context in comments.

Comments

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

Please use this code for on click event refresh page.

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.