0

I have mentioned the javascript code

 function submitCmdFile(  )
 {
    var dialog = $("#dialog").dialog({
    resizable: false,
    height: 200,
    modal: true,
    buttons: {
    "Submit": function () {
     $("#dialog").find("form").submit();
     $(this).dialog("close");
    },
    "Cancel": function () {
    $(this).dialog("close");
    }
    }
});
}

In this code, How to get the submit button value to php?

R3tep
  • 12,512
  • 10
  • 48
  • 75
nani
  • 75
  • 7
  • you have to fire a request to your php file... check this out: http://www.w3schools.com/jquery/jquery_ajax_get_post.asp – K. Bastian May 18 '16 at 09:03

2 Answers2

-1

Simplest way is to do a ajax call to your php file.

Try this:

function submitCmdFile() {
    var dialog = $("#dialog").dialog({
        resizable: false,
        height: 200,
        modal: true,
        buttons: {
            "Submit": function () {
                $("#dialog").find("form").submit();
                $(this).dialog("close");

                $(this).click(function(){
                    $.get('yourfile.php', function(data){
                        // response from the php file will be here
                    })
                })

            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    });
}
Martin Gottweis
  • 2,721
  • 13
  • 27
-1

Here's a simplest ways to post your form data to php file.

Your Javascript Code:

var inputValues= $('.myForm').serialize();
function submitCmdFile() {
    var dialog = $("#dialog").dialog({
        resizable: false,
        height: 200,
        modal: true,
        buttons: {
            "Submit": function () {
                $("#dialog").find("form").submit();
                $(this).dialog("close");
                var formData = $('#myForm').serialize();
                $.ajax({
                    url: "myfile.php",
                    type: "POST",
                    data: formData,
                    success: function(data){
                        alert(data);
                        // or use: console.log(data); /*you need firebug to log*/
                    }
                });
            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    });
}

Your PHP Code: (myfile.php)

if(isset($_POST)){
   var_dump($_POST);
}
Rahul K
  • 413
  • 3
  • 11