javascript - jquery弹出在post方法中提交表单

标签 javascript php jquery html forms

这是我的表格

<form method="POST" action="adddriverprocess.php" enctype="multipart/form-data">
<...>
<...>
</form>

在提交 <input type="submit" value="Submit"/> 中效果很好

我试图在其中添加 jquery 弹出窗口,通过按表单应该执行 post 操作。行动。

所以,我有这个 jquery 按钮

<a href="javascript:;" id="<?php echo url();?>/adddriverprocess.php" class="btnActivation"><button class="delete-btn btn-sm"><span class="icon"></span></button></a></td>

$('.btnActivation').click(fnActivation);
  function fnActivation() {
        var url =$(this).attr("id");
    $("#dialog-confirms").html("Are you sure you want to submit this form ?");
var buttonsConfig = [
    {
        text: "Yes",
        "class": "ok",
        click: function() {
        $(this).dialog('close');
        window.location.href=url;
        }
    },
    {
        text: "Cancel",
        "class": "cancel",
        click: function() {
        $(this).dialog('close');
        }
    }
];
    $("#dialog-confirms").dialog({
        resizable: false,
        modal: true,
        title: "Ma$na Taxi",
        height: 250,
        width: 400,
        buttons: buttonsConfig,
    });
}

弹出窗口很好,但是当我按下“确定”按钮时,它会将我带到 adddriverprocess,但在 get 中方法,但我希望它在 post 中执行方法与名称中填写的数据。

我该怎么做?

最佳答案

在您的表单上添加 ID,并更改"is"点击功能以发布您的表单而不是位置。

更改此:

click: function() {
    $(this).dialog('close');
    window.location.href=url;
}

对此:

click: function() {
    $('#MyForm').submit();
    $(this).dialog('close');
}

这里是 jQuery Submit() 文档: http://api.jquery.com/submit/

关于javascript - jquery弹出在post方法中提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28290067/

相关文章:

javascript - 将文本附加到 D3 力布局图

javascript - 如何解读逆变器功率值?

php - 添加 Rest API 响应到 MySQL 数据库

javascript - 顶部的粘性标题更改颜色

php - 将 JS 与 PHP var 放在一起

一个类的实例的Javascript数组

php - 无法使用PHP将数据从excel上传到mysql

php - 有没有办法使用远程机器的 CPU 在 ffmpeg 中进行转换?

php - SilverStripe - 自定义分面搜索导航

javascript - 从弹出窗口中选择图像并显示在主页中