【问题标题】:didn't get value in post which was set by jquery [closed]没有在 jquery 设置的帖子中获得价值 [关闭]
【发布时间】:2017-04-19 12:00:36
【问题描述】:
<html>
    <body>
        <form name="trim_video_form" id="trim_video_form" action="video_ajax.php?v=54f85644" method="post">
            <input type="hidden" name="action" value="crop_video">

            <div class="trim_video_outr">
                <!--<iframe src="embed.php?v=54f85644&statTrack=&w=512&h=288&iframe=1&trimmingType=video" width="512" height="288" frameborder="0" scrolling="no" id="trim_video_popup_iframe"></iframe>-->
                <iframe src="http://easyweb.site/embed.php?v=54f85644&amp;statTrack=&amp;w=512&amp;h=288&amp;iframe=1&amp;trimmingType=video" width="591" height="335" frameborder="0" scrolling="no" id="trim_video_popup_iframe"></iframe>

            </div>

            <div class="show_time_row">

                From : &nbsp;<input type="text" name="start_time_show" style="width:60px;" class="start_time_show show_time_input">

                <input type="hidden" name="start_time" style="width:60px;" class="start_time" value="Left-Flag">&nbsp; 

                To : &nbsp;<input type="text" name="end_time_show" style="width:60px;" class="end_time_show show_time_input">

                <input type="hidden" name="end_time" style="width:60px;" class="end_time" value="24.24641666666667"> &nbsp; Seconds

            </div>

            <div style="margin:14px 0; color:#676767;">

                <input type="radio" name="save_new" class="save_new" value="1" checked="checked"> Save As New Video

                <input type="radio" name="save_new" class="save_new" value="0" style="margin-left:15px;"> Overwrite Original<br>

            </div>

            <div class="trim_video_title">Video Title : &nbsp; <input type="text" name="video_title" value="" class="video_title_input trim_title"><br><br></div>

            <input type="button" name="upload" id="trim_image_btn" value="Trim Video" class="blackbtn">
        </form>
        <input type="hidden" value="">
        <input type="submit" >
        </form>
    </body>
</html>

js代码

function trimVideo(startTime, endTime)
{
    $('.start_time').val(startTime);
    $('.end_time').val(endTime);
    var startTime = secondsToHms(startTime);
    var endTime = secondsToHms(endTime);
    $('.start_time_show').val(startTime);
    $('.end_time_show').val(endTime);
}

php代码

if ($_POST['action'] == "crop_video") { echo '<pre>';var_dump($_POST);die('in ajax');}

js 函数在值变化时被调用。 此 php 代码在 ajax 方法中调用。

我可以看到 value 属性与它的值一起添加到输入字段中。 我正在使用 jQuery 设置输入值。浏览器显示该值。但是当我使用 POST 提交它时,php 文件中的 POST 显示输入值为空。为什么

【问题讨论】:

  • 能否请您更新您的完整代码,这些东西不足以给出您的答案,用jquare和php代码更新
  • 输入类型隐藏,值被清空,你期望一些数据如何???
  • 这是 html 不是 jquery 并且写得很糟糕的 html @AsifUddin 是的也看到了,哈哈
  • 是的,这太多了 ;) 大声笑@Gert

标签: javascript php jquery


【解决方案1】:

我相信那是因为你缺少属性name

HTML

<input type="hidden" name="someProperty" value="">

PHP

<?php echo $_POST['someProperty']; ?>

【讨论】:

  • 也许可以,但没有他的完整代码,你不能说这是个问题
  • 这也不会给你带来任何价值,因为 value 仍然是 value=""
【解决方案2】:

不幸的是,有一个代码覆盖了在 POST 上提交的值。这就是为什么 POST 参数在接收时变为空的原因。这段代码没有错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-30
    • 1970-01-01
    • 1970-01-01
    • 2021-09-17
    相关资源
    最近更新 更多