简体   繁体   中英

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);
    });

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();
});
$('#submit').click(function() {
    location.reload();
});

Please use this code for on click event refresh page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM