wawan Setiyawan wawan Setiyawan - 1 year ago 70
Ajax Question

getting form to ajax with submit button outside form

i have multiple form, so i create a form with button submit outside form, this form

$("#buttonSubmit").click(function (event) {
if (confirm("Anda yakin akan Checkout ?")) {
var formData = new FormData("form#formData");
url: 'belanja/belanja_crud.php',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
dataType: 'json',
success: function (data) {
return false;

<form id='formData'>
<!-- input bla bla bla -->
<button id='buttonSubmit' type='button'>Submit</button>

how to get all input from form on above and submit with ajax ?

Answer Source

To get all data in the form in one instruction you can use .serialize()


    type: "POST",
    url: 'belanja/belanja_crud.php',
    data: $("#formData").serialize()
.done(function (data) {
    //do somthing
.fail(function (xhr, ajaxOptions, thrownError) {
    //do something

Or you can see this topic if you want it to JSON Format

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download