【发布时间】:2019-10-25 06:23:40
【问题描述】:
我正在处理 html 表格行(目前是两个),如下所示,其中单击按钮:
=> JS/jQuery 代码被调用(其中 Go 文本更改为 Converting)
=> 然后通过 AJAX 编写 convert.php 脚本,在该脚本中将 mp4 转换为 mp3。
html/php代码:
<?php foreach ($programs as $key => $program) { ?>
<tr data-index="<?php echo $key; ?>">
<td><input type="submit" id="go-btn" name="go-button" value="Go" data-id="<?php echo $key; ?>" ></input></td>
</tr>
<?php }?>
转换.php:
$f = $mp4_files[$_POST['id']];
$parts = pathinfo($f);
switch ($parts['extension'])
{
case 'mp4' :
$filePath = $src_dir . DS . $f;
system('C:\ffmpeg\bin\ffmpeg.exe -i ' . $filePath . ' -map 0:2 -ac 1 ' . $destination_dir . DS . $parts['filename'] . '.mp3', $result);
print_r("Hello World");
break;
}
JS/jQuery 代码:
$("input[name='go-button']").click( function() {
// Change the text of the button, and disable
$(this).val("Converting").attr("disabled", "true");
});
只要单击上面 html/php 代码中的按钮,UI 中的文本就会从 Go 更改为 Converting因为我在我的代码库中添加了 JS/jQuery 代码,但是我添加的这个 JS/jQuery 代码只更改了文本。 它实际上并不知道转换是在后台发生的。
问题陈述:
我想知道我需要在上面的 JS/jQuery 代码中做哪些修改,以便 UI 真正知道转换是在后台发生的。
可能,我们需要在 JS/jQuery 和上面的 php 代码之间添加 make 建立一些连接,但我不确定我们该怎么做。
【问题讨论】:
-
您的问题并不完全清楚。如果“UI 确实知道正在发生转换”,您认为它应该是什么样子?你想看“Go”->“Converting”->“Converted”吗?
标签: javascript php ajax upload progress-bar