ABD
ABD

Reputation: 889

jquery popup submit the form in post method

Here is my form

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

It works good in the submit <input type="submit" value="Submit"/>

I am trying to have the jquery popup in it, where by pressing the form should do the post action.

So, i had this jquery button

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

With

$('.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,
    });
}

The popup comes good, but when i press the ok button it takes me to the adddriverprocess but in get method but i want it to do in post method with the datas that is filled in the name.

How can i do this ?

Upvotes: 1

Views: 1108

Answers (1)

Tom Faltesek
Tom Faltesek

Reputation: 2818

Put an ID on your form and change your "Yes" click function to post your form instead of the location.

Change this:

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

To this:

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

Here's the jQuery submit() documentation: http://api.jquery.com/submit/

Upvotes: 1

Related Questions